mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 01:45:36 +03:00
Changes code style when arrow alignment
This commit is contained in:
parent
3f3662e605
commit
b3fdb5ed17
553 changed files with 3106 additions and 3106 deletions
|
@ -764,7 +764,7 @@ ij_groovy_while_on_new_line = false
|
|||
ij_groovy_wrap_long_lines = false
|
||||
|
||||
[{*.gradle.kts,*.kt,*.kts,*.main.kts}]
|
||||
ij_kotlin_align_in_columns_case_branch = true
|
||||
ij_kotlin_align_in_columns_case_branch = false
|
||||
ij_kotlin_align_multiline_binary_operation = false
|
||||
ij_kotlin_align_multiline_extends_list = false
|
||||
ij_kotlin_align_multiline_method_parentheses = false
|
||||
|
|
|
@ -271,7 +271,7 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi
|
|||
directionDetector.handleTouchEvent(event)
|
||||
|
||||
return when (swipeDirection) {
|
||||
SwipeDirection.Up, SwipeDirection.Down -> {
|
||||
SwipeDirection.Up, SwipeDirection.Down -> {
|
||||
if (isSwipeToDismissAllowed && !wasScaled && isImagePagerIdle) {
|
||||
swipeDismissHandler.onTouch(views.rootContainer, event)
|
||||
} else true
|
||||
|
@ -279,7 +279,7 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi
|
|||
SwipeDirection.Left, SwipeDirection.Right -> {
|
||||
views.attachmentPager.dispatchTouchEvent(event)
|
||||
}
|
||||
else -> true
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,18 +42,18 @@ class AttachmentsAdapter : RecyclerView.Adapter<BaseViewHolder>() {
|
|||
val inflater = LayoutInflater.from(parent.context)
|
||||
val itemView = inflater.inflate(viewType, parent, false)
|
||||
return when (viewType) {
|
||||
R.layout.item_image_attachment -> ZoomableImageViewHolder(itemView)
|
||||
R.layout.item_image_attachment -> ZoomableImageViewHolder(itemView)
|
||||
R.layout.item_animated_image_attachment -> AnimatedImageViewHolder(itemView)
|
||||
R.layout.item_video_attachment -> VideoViewHolder(itemView)
|
||||
else -> UnsupportedViewHolder(itemView)
|
||||
R.layout.item_video_attachment -> VideoViewHolder(itemView)
|
||||
else -> UnsupportedViewHolder(itemView)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
val info = attachmentSourceProvider!!.getAttachmentInfoAt(position)
|
||||
return when (info) {
|
||||
is AttachmentInfo.Image -> R.layout.item_image_attachment
|
||||
is AttachmentInfo.Video -> R.layout.item_video_attachment
|
||||
is AttachmentInfo.Image -> R.layout.item_image_attachment
|
||||
is AttachmentInfo.Video -> R.layout.item_video_attachment
|
||||
is AttachmentInfo.AnimatedImage -> R.layout.item_animated_image_attachment
|
||||
// is AttachmentInfo.Audio -> TODO()
|
||||
// is AttachmentInfo.File -> TODO()
|
||||
|
@ -68,13 +68,13 @@ class AttachmentsAdapter : RecyclerView.Adapter<BaseViewHolder>() {
|
|||
attachmentSourceProvider?.getAttachmentInfoAt(position)?.let {
|
||||
holder.bind(it)
|
||||
when (it) {
|
||||
is AttachmentInfo.Image -> {
|
||||
is AttachmentInfo.Image -> {
|
||||
attachmentSourceProvider?.loadImage((holder as ZoomableImageViewHolder).target, it)
|
||||
}
|
||||
is AttachmentInfo.AnimatedImage -> {
|
||||
attachmentSourceProvider?.loadImage((holder as AnimatedImageViewHolder).target, it)
|
||||
}
|
||||
is AttachmentInfo.Video -> {
|
||||
is AttachmentInfo.Video -> {
|
||||
attachmentSourceProvider?.loadVideo((holder as VideoViewHolder).target, it)
|
||||
}
|
||||
// else -> {
|
||||
|
|
|
@ -27,12 +27,12 @@ sealed class SwipeDirection {
|
|||
companion object {
|
||||
fun fromAngle(angle: Double): SwipeDirection {
|
||||
return when (angle) {
|
||||
in 0.0..45.0 -> Right
|
||||
in 45.0..135.0 -> Up
|
||||
in 0.0..45.0 -> Right
|
||||
in 45.0..135.0 -> Up
|
||||
in 135.0..225.0 -> Left
|
||||
in 225.0..315.0 -> Down
|
||||
in 315.0..360.0 -> Right
|
||||
else -> NotDetected
|
||||
else -> NotDetected
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class SwipeDirectionDetector(
|
|||
|
||||
fun handleTouchEvent(event: MotionEvent) {
|
||||
when (event.action) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
startX = event.x
|
||||
startY = event.y
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class SwipeDirectionDetector(
|
|||
startX = startY
|
||||
isDetected = false
|
||||
}
|
||||
MotionEvent.ACTION_MOVE -> if (!isDetected && getEventDistance(event) > touchSlop) {
|
||||
MotionEvent.ACTION_MOVE -> if (!isDetected && getEventDistance(event) > touchSlop) {
|
||||
isDetected = true
|
||||
onDirectionDetected(getDirection(startX, startY, event.x, event.y))
|
||||
}
|
||||
|
|
|
@ -79,8 +79,8 @@ class SwipeToDismissHandler(
|
|||
private fun onTrackingEnd(parentHeight: Int) {
|
||||
val animateTo = when {
|
||||
swipeView.translationY < -translationLimit -> -parentHeight.toFloat()
|
||||
swipeView.translationY > translationLimit -> parentHeight.toFloat()
|
||||
else -> 0f
|
||||
swipeView.translationY > translationLimit -> parentHeight.toFloat()
|
||||
else -> 0f
|
||||
}
|
||||
|
||||
if (animateTo != 0f && !shouldAnimateDismiss()) {
|
||||
|
|
|
@ -146,7 +146,7 @@ class VideoViewHolder constructor(itemView: View) :
|
|||
wasPaused = true
|
||||
views.videoView.pause()
|
||||
}
|
||||
is AttachmentCommands.SeekTo -> {
|
||||
is AttachmentCommands.SeekTo -> {
|
||||
val duration = views.videoView.duration
|
||||
if (duration > 0) {
|
||||
val seekDuration = duration * (commands.percentProgress / 100f)
|
||||
|
|
|
@ -43,7 +43,7 @@ internal class JSonViewerEpoxyController(private val context: Context) :
|
|||
text(async.error.localizedMessage?.toEpoxyCharSequence())
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
async.invoke()?.let {
|
||||
buildRec(it, 0, "")
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ internal class JSonViewerEpoxyController(private val context: Context) :
|
|||
}
|
||||
}
|
||||
}
|
||||
is JSonViewerArray -> {
|
||||
is JSonViewerArray -> {
|
||||
if (model.isExpanded) {
|
||||
open(id, model.key, model.index, depth, false, model)
|
||||
model.items.forEach {
|
||||
|
@ -137,7 +137,7 @@ internal class JSonViewerEpoxyController(private val context: Context) :
|
|||
}
|
||||
}
|
||||
}
|
||||
is JSonViewerLeaf -> {
|
||||
is JSonViewerLeaf -> {
|
||||
valueItem {
|
||||
id(id)
|
||||
depth(depth)
|
||||
|
@ -172,12 +172,12 @@ internal class JSonViewerEpoxyController(private val context: Context) :
|
|||
private fun valueToSpan(leaf: JSonViewerLeaf): Span {
|
||||
val host = this
|
||||
return when (leaf.type) {
|
||||
JSONType.STRING -> {
|
||||
JSONType.STRING -> {
|
||||
span("\"${leaf.stringRes}\"") {
|
||||
textColor = host.styleProvider.stringColor
|
||||
}
|
||||
}
|
||||
JSONType.NUMBER -> {
|
||||
JSONType.NUMBER -> {
|
||||
span(leaf.stringRes) {
|
||||
textColor = host.styleProvider.numberColor
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ internal class JSonViewerEpoxyController(private val context: Context) :
|
|||
textColor = host.styleProvider.booleanColor
|
||||
}
|
||||
}
|
||||
JSONType.NULL -> {
|
||||
JSONType.NULL -> {
|
||||
span("null") {
|
||||
textColor = host.styleProvider.booleanColor
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ internal object ModelParser {
|
|||
}
|
||||
parent.addChild(objectComposed)
|
||||
}
|
||||
is JSONArray -> {
|
||||
is JSONArray -> {
|
||||
val objectComposed = JSonViewerArray(key, index, obj)
|
||||
.apply { isExpanded = initialOpenDepth == -1 || depth <= initialOpenDepth }
|
||||
objectComposed.depth = depth
|
||||
|
@ -91,25 +91,25 @@ internal object ModelParser {
|
|||
}
|
||||
parent.addChild(objectComposed)
|
||||
}
|
||||
is String -> {
|
||||
is String -> {
|
||||
JSonViewerLeaf(key, index, obj, JSONType.STRING).let {
|
||||
it.depth = depth
|
||||
parent.addChild(it)
|
||||
}
|
||||
}
|
||||
is Number -> {
|
||||
is Number -> {
|
||||
JSonViewerLeaf(key, index, obj.toString(), JSONType.NUMBER).let {
|
||||
it.depth = depth
|
||||
parent.addChild(it)
|
||||
}
|
||||
}
|
||||
is Boolean -> {
|
||||
is Boolean -> {
|
||||
JSonViewerLeaf(key, index, obj.toString(), JSONType.BOOLEAN).let {
|
||||
it.depth = depth
|
||||
parent.addChild(it)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
if (obj == JSONObject.NULL) {
|
||||
JSonViewerLeaf(key, index, "null", JSONType.NULL).let {
|
||||
it.depth = depth
|
||||
|
|
|
@ -48,7 +48,7 @@ class FilePicker : Picker<MultiPickerBaseType>() {
|
|||
type.isMimeTypeVideo() -> selectedUri.toMultiPickerVideoType(context)
|
||||
type.isMimeTypeImage() -> selectedUri.toMultiPickerImageType(context)
|
||||
type.isMimeTypeAudio() -> selectedUri.toMultiPickerAudioType(context)
|
||||
else -> {
|
||||
else -> {
|
||||
// Other files
|
||||
context.contentResolver.query(selectedUri, null, null, null, null)
|
||||
?.use { cursor ->
|
||||
|
|
|
@ -31,15 +31,15 @@ class MultiPicker<T> private constructor() {
|
|||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> get(type: MultiPicker<T>): T {
|
||||
return when (type) {
|
||||
IMAGE -> ImagePicker() as T
|
||||
VIDEO -> VideoPicker() as T
|
||||
MEDIA -> MediaPicker() as T
|
||||
FILE -> FilePicker() as T
|
||||
AUDIO -> AudioPicker() as T
|
||||
CONTACT -> ContactPicker() as T
|
||||
CAMERA -> CameraPicker() as T
|
||||
IMAGE -> ImagePicker() as T
|
||||
VIDEO -> VideoPicker() as T
|
||||
MEDIA -> MediaPicker() as T
|
||||
FILE -> FilePicker() as T
|
||||
AUDIO -> AudioPicker() as T
|
||||
CONTACT -> ContactPicker() as T
|
||||
CAMERA -> CameraPicker() as T
|
||||
CAMERA_VIDEO -> CameraVideoPicker() as T
|
||||
else -> throw IllegalArgumentException("Unsupported type $type")
|
||||
else -> throw IllegalArgumentException("Unsupported type $type")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -651,7 +651,7 @@ class E2eeSanityTests : InstrumentedTest {
|
|||
// we can release this latch?
|
||||
oldCompleteLatch.countDown()
|
||||
}
|
||||
else -> Unit
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -678,17 +678,17 @@ class E2eeSanityTests : InstrumentedTest {
|
|||
IncomingSasVerificationTransaction.UxState.SHOW_ACCEPT -> {
|
||||
// no need to accept as there was a request first it will auto accept
|
||||
}
|
||||
IncomingSasVerificationTransaction.UxState.SHOW_SAS -> {
|
||||
IncomingSasVerificationTransaction.UxState.SHOW_SAS -> {
|
||||
if (matchOnce) {
|
||||
sasTx.userHasVerifiedShortCode()
|
||||
newCode = sasTx.getDecimalCodeRepresentation()
|
||||
matchOnce = false
|
||||
}
|
||||
}
|
||||
IncomingSasVerificationTransaction.UxState.VERIFIED -> {
|
||||
IncomingSasVerificationTransaction.UxState.VERIFIED -> {
|
||||
newCompleteLatch.countDown()
|
||||
}
|
||||
else -> Unit
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -439,7 +439,7 @@ class SASTest : InstrumentedTest {
|
|||
OutgoingSasVerificationTransaction.UxState.SHOW_SAS -> {
|
||||
aliceSASLatch.countDown()
|
||||
}
|
||||
else -> Unit
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -453,7 +453,7 @@ class SASTest : InstrumentedTest {
|
|||
IncomingSasVerificationTransaction.UxState.SHOW_ACCEPT -> {
|
||||
tx.performAccept()
|
||||
}
|
||||
else -> Unit
|
||||
else -> Unit
|
||||
}
|
||||
if (uxState === IncomingSasVerificationTransaction.UxState.SHOW_SAS) {
|
||||
bobSASLatch.countDown()
|
||||
|
@ -507,7 +507,7 @@ class SASTest : InstrumentedTest {
|
|||
aliceSASLatch.countDown()
|
||||
}
|
||||
}
|
||||
else -> Unit
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -527,16 +527,16 @@ class SASTest : InstrumentedTest {
|
|||
tx.performAccept()
|
||||
}
|
||||
}
|
||||
IncomingSasVerificationTransaction.UxState.SHOW_SAS -> {
|
||||
IncomingSasVerificationTransaction.UxState.SHOW_SAS -> {
|
||||
if (matchOnce) {
|
||||
matchOnce = false
|
||||
tx.userHasVerifiedShortCode()
|
||||
}
|
||||
}
|
||||
IncomingSasVerificationTransaction.UxState.VERIFIED -> {
|
||||
IncomingSasVerificationTransaction.UxState.VERIFIED -> {
|
||||
bobSASLatch.countDown()
|
||||
}
|
||||
else -> Unit
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class TestPermalinkService : PermalinkService {
|
|||
|
||||
override fun createMentionSpanTemplate(type: PermalinkService.SpanTemplateType, forceMatrixTo: Boolean): String {
|
||||
return when (type) {
|
||||
HTML -> "<a href=\"https://matrix.to/#/%1\$s\">%2\$s</a>"
|
||||
HTML -> "<a href=\"https://matrix.to/#/%1\$s\">%2\$s</a>"
|
||||
MARKDOWN -> "[%2\$s](https://matrix.to/#/%1\$s)"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ class PollAggregationTest : InstrumentedTest {
|
|||
}
|
||||
|
||||
when (lock.count.toInt()) {
|
||||
TOTAL_TEST_COUNT -> {
|
||||
TOTAL_TEST_COUNT -> {
|
||||
// Poll has just been created.
|
||||
testInitialPollConditions(pollContent, pollSummary)
|
||||
lock.countDown()
|
||||
|
@ -122,7 +122,7 @@ class PollAggregationTest : InstrumentedTest {
|
|||
testEndedPoll(pollSummary)
|
||||
lock.countDown()
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
fail("Lock count ${lock.count} didn't handled.")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,14 +26,14 @@ internal class InlineMaths(private val delimiter: InlineDelimiter) : CustomNode(
|
|||
|
||||
override fun getOpeningDelimiter(): String {
|
||||
return when (delimiter) {
|
||||
InlineDelimiter.SINGLE_DOLLAR -> "$"
|
||||
InlineDelimiter.SINGLE_DOLLAR -> "$"
|
||||
InlineDelimiter.ROUND_BRACKET_ESCAPED -> "\\("
|
||||
}
|
||||
}
|
||||
|
||||
override fun getClosingDelimiter(): String {
|
||||
return when (delimiter) {
|
||||
InlineDelimiter.SINGLE_DOLLAR -> "$"
|
||||
InlineDelimiter.SINGLE_DOLLAR -> "$"
|
||||
InlineDelimiter.ROUND_BRACKET_ESCAPED -> "\\)"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,8 +69,8 @@ fun TermPolicies.toLocalizedLoginTerms(
|
|||
// Search for language
|
||||
policy.keys.forEach { policyKey ->
|
||||
when (policyKey) {
|
||||
"version" -> Unit // Ignore
|
||||
userLanguage -> {
|
||||
"version" -> Unit // Ignore
|
||||
userLanguage -> {
|
||||
// We found the data for the user language
|
||||
userLanguageUrlAndName = extractUrlAndName(policy[policyKey])
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ fun TermPolicies.toLocalizedLoginTerms(
|
|||
// We found default language
|
||||
defaultLanguageUrlAndName = extractUrlAndName(policy[policyKey])
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
if (firstUrlAndName == null) {
|
||||
// Get at least some data
|
||||
firstUrlAndName = extractUrlAndName(policy[policyKey])
|
||||
|
@ -89,7 +89,7 @@ fun TermPolicies.toLocalizedLoginTerms(
|
|||
|
||||
// Copy found language data by priority
|
||||
when {
|
||||
userLanguageUrlAndName != null -> {
|
||||
userLanguageUrlAndName != null -> {
|
||||
localizedFlowDataLoginTermsLocalizedUrl = userLanguageUrlAndName!!.url
|
||||
localizedFlowDataLoginTermsLocalizedName = userLanguageUrlAndName!!.name
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ fun TermPolicies.toLocalizedLoginTerms(
|
|||
localizedFlowDataLoginTermsLocalizedUrl = defaultLanguageUrlAndName!!.url
|
||||
localizedFlowDataLoginTermsLocalizedName = defaultLanguageUrlAndName!!.name
|
||||
}
|
||||
firstUrlAndName != null -> {
|
||||
firstUrlAndName != null -> {
|
||||
localizedFlowDataLoginTermsLocalizedUrl = firstUrlAndName!!.url
|
||||
localizedFlowDataLoginTermsLocalizedName = firstUrlAndName!!.name
|
||||
}
|
||||
|
|
|
@ -66,17 +66,17 @@ data class SsoIdentityProvider(
|
|||
private fun toPriority(): Int {
|
||||
return when (brand) {
|
||||
// We are on Android, so user is more likely to have a Google account
|
||||
BRAND_GOOGLE -> 5
|
||||
BRAND_GOOGLE -> 5
|
||||
// Facebook is also an important SSO provider
|
||||
BRAND_FACEBOOK -> 4
|
||||
// Twitter is more for professionals
|
||||
BRAND_TWITTER -> 3
|
||||
BRAND_TWITTER -> 3
|
||||
// Here it's very for techie people
|
||||
BRAND_GITHUB,
|
||||
BRAND_GITLAB -> 2
|
||||
BRAND_GITLAB -> 2
|
||||
// And finally, if the account has been created with an iPhone...
|
||||
BRAND_APPLE -> 1
|
||||
else -> 0
|
||||
BRAND_APPLE -> 1
|
||||
else -> 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,15 +88,15 @@ fun RegistrationFlowResponse.toFlowResult(): FlowResult {
|
|||
val isMandatory = flows?.all { type in it.stages.orEmpty() } == true
|
||||
|
||||
val stage = when (type) {
|
||||
LoginFlowTypes.RECAPTCHA -> Stage.ReCaptcha(
|
||||
LoginFlowTypes.RECAPTCHA -> Stage.ReCaptcha(
|
||||
isMandatory, ((params?.get(type) as? Map<*, *>)?.get("public_key") as? String)
|
||||
?: ""
|
||||
)
|
||||
LoginFlowTypes.DUMMY -> Stage.Dummy(isMandatory)
|
||||
LoginFlowTypes.TERMS -> Stage.Terms(isMandatory, params?.get(type) as? TermPolicies ?: emptyMap<String, String>())
|
||||
LoginFlowTypes.DUMMY -> Stage.Dummy(isMandatory)
|
||||
LoginFlowTypes.TERMS -> Stage.Terms(isMandatory, params?.get(type) as? TermPolicies ?: emptyMap<String, String>())
|
||||
LoginFlowTypes.EMAIL_IDENTITY -> Stage.Email(isMandatory)
|
||||
LoginFlowTypes.MSISDN -> Stage.Msisdn(isMandatory)
|
||||
else -> Stage.Other(isMandatory, type, (params?.get(type) as? Map<*, *>))
|
||||
LoginFlowTypes.MSISDN -> Stage.Msisdn(isMandatory)
|
||||
else -> Stage.Other(isMandatory, type, (params?.get(type) as? Map<*, *>))
|
||||
}
|
||||
|
||||
if (type in completedStages.orEmpty()) {
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.matrix.android.sdk.api.extensions
|
|||
fun CharSequence.ensurePrefix(prefix: CharSequence): CharSequence {
|
||||
return when {
|
||||
startsWith(prefix) -> this
|
||||
else -> "$prefix$this"
|
||||
else -> "$prefix$this"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ data class Fingerprint(
|
|||
internal fun matchesCert(cert: X509Certificate): Boolean {
|
||||
val o: Fingerprint? = when (hashType) {
|
||||
HashType.SHA256 -> newSha256Fingerprint(cert)
|
||||
HashType.SHA1 -> newSha1Fingerprint(cert)
|
||||
HashType.SHA1 -> newSha1Fingerprint(cert)
|
||||
}
|
||||
return equals(o)
|
||||
}
|
||||
|
|
|
@ -24,5 +24,5 @@ sealed interface KeysBackupLastVersionResult {
|
|||
|
||||
fun KeysBackupLastVersionResult.toKeysVersionResult(): KeysVersionResult? = when (this) {
|
||||
is KeysBackupLastVersionResult.KeysBackup -> keysVersionResult
|
||||
KeysBackupLastVersionResult.NoKeysBackup -> null
|
||||
KeysBackupLastVersionResult.NoKeysBackup -> null
|
||||
}
|
||||
|
|
|
@ -212,13 +212,13 @@ data class Event(
|
|||
|
||||
return when {
|
||||
isReplyRenderedInThread() || isQuote() -> ContentUtils.extractUsefulTextFromReply(text)
|
||||
isFileMessage() -> "sent a file."
|
||||
isAudioMessage() -> "sent an audio file."
|
||||
isImageMessage() -> "sent an image."
|
||||
isVideoMessage() -> "sent a video."
|
||||
isSticker() -> "sent a sticker"
|
||||
isPoll() -> getPollQuestion() ?: "created a poll."
|
||||
else -> text
|
||||
isFileMessage() -> "sent a file."
|
||||
isAudioMessage() -> "sent an audio file."
|
||||
isImageMessage() -> "sent an image."
|
||||
isVideoMessage() -> "sent a video."
|
||||
isSticker() -> "sent a sticker"
|
||||
isPoll() -> getPollQuestion() ?: "created a poll."
|
||||
else -> text
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -318,35 +318,35 @@ fun Event.isTextMessage(): Boolean {
|
|||
MessageType.MSGTYPE_TEXT,
|
||||
MessageType.MSGTYPE_EMOTE,
|
||||
MessageType.MSGTYPE_NOTICE -> true
|
||||
else -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun Event.isImageMessage(): Boolean {
|
||||
return when (getMsgType()) {
|
||||
MessageType.MSGTYPE_IMAGE -> true
|
||||
else -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun Event.isVideoMessage(): Boolean {
|
||||
return when (getMsgType()) {
|
||||
MessageType.MSGTYPE_VIDEO -> true
|
||||
else -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun Event.isAudioMessage(): Boolean {
|
||||
return when (getMsgType()) {
|
||||
MessageType.MSGTYPE_AUDIO -> true
|
||||
else -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun Event.isFileMessage(): Boolean {
|
||||
return when (getMsgType()) {
|
||||
MessageType.MSGTYPE_FILE -> true
|
||||
else -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -356,14 +356,14 @@ fun Event.isAttachmentMessage(): Boolean {
|
|||
MessageType.MSGTYPE_AUDIO,
|
||||
MessageType.MSGTYPE_VIDEO,
|
||||
MessageType.MSGTYPE_FILE -> true
|
||||
else -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun Event.isLocationMessage(): Boolean {
|
||||
return when (getMsgType()) {
|
||||
MessageType.MSGTYPE_LOCATION -> true
|
||||
else -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -378,9 +378,9 @@ fun Event.getRelationContent(): RelationDefaultContent? {
|
|||
content.toModel<MessageContent>()?.relatesTo ?: run {
|
||||
// Special cases when there is only a local msgtype for some event types
|
||||
when (getClearType()) {
|
||||
EventType.STICKER -> getClearContent().toModel<MessageStickerContent>()?.relatesTo
|
||||
EventType.STICKER -> getClearContent().toModel<MessageStickerContent>()?.relatesTo
|
||||
in EventType.BEACON_LOCATION_DATA -> getClearContent().toModel<MessageBeaconLocationDataContent>()?.relatesTo
|
||||
else -> null
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,12 +98,12 @@ enum class WithHeldCode(val value: String) {
|
|||
companion object {
|
||||
fun fromCode(code: String?): WithHeldCode? {
|
||||
return when (code) {
|
||||
BLACKLISTED.value -> BLACKLISTED
|
||||
UNVERIFIED.value -> UNVERIFIED
|
||||
BLACKLISTED.value -> BLACKLISTED
|
||||
UNVERIFIED.value -> UNVERIFIED
|
||||
UNAUTHORISED.value -> UNAUTHORISED
|
||||
UNAVAILABLE.value -> UNAVAILABLE
|
||||
NO_OLM.value -> NO_OLM
|
||||
else -> null
|
||||
UNAVAILABLE.value -> UNAVAILABLE
|
||||
NO_OLM.value -> NO_OLM
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,13 +81,13 @@ data class HomeServerCapabilities(
|
|||
val versionCap = roomVersions.supportedVersion.firstOrNull { it.version == preferred }
|
||||
|
||||
return when {
|
||||
versionCap == null -> {
|
||||
versionCap == null -> {
|
||||
RoomCapabilitySupport.UNKNOWN
|
||||
}
|
||||
versionCap.status == RoomVersionStatus.STABLE -> {
|
||||
RoomCapabilitySupport.SUPPORTED
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
RoomCapabilitySupport.SUPPORTED_UNSTABLE
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ sealed class ThreePid(open val value: String) {
|
|||
|
||||
internal fun ThreePid.toMedium(): String {
|
||||
return when (this) {
|
||||
is ThreePid.Email -> ThirdPartyIdentifier.MEDIUM_EMAIL
|
||||
is ThreePid.Email -> ThirdPartyIdentifier.MEDIUM_EMAIL
|
||||
is ThreePid.Msisdn -> ThirdPartyIdentifier.MEDIUM_MSISDN
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,12 +38,12 @@ object MatrixToConverter {
|
|||
// URL is already a matrix.to
|
||||
uriString.startsWith(PermalinkService.MATRIX_TO_URL_BASE) -> uri
|
||||
// Web or client url
|
||||
SUPPORTED_PATHS.any { it in uriString } -> {
|
||||
SUPPORTED_PATHS.any { it in uriString } -> {
|
||||
val path = SUPPORTED_PATHS.first { it in uriString }
|
||||
Uri.parse(PermalinkService.MATRIX_TO_URL_BASE + uriString.substringAfter(path))
|
||||
}
|
||||
// URL is not supported
|
||||
else -> null
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,10 +67,10 @@ object PermalinkParser {
|
|||
val identifier = params.getOrNull(0)
|
||||
val extraParameter = params.getOrNull(1)
|
||||
return when {
|
||||
identifier.isNullOrEmpty() -> PermalinkData.FallbackLink(uri)
|
||||
MatrixPatterns.isUserId(identifier) -> PermalinkData.UserLink(userId = identifier)
|
||||
MatrixPatterns.isGroupId(identifier) -> PermalinkData.GroupLink(groupId = identifier)
|
||||
MatrixPatterns.isRoomId(identifier) -> {
|
||||
identifier.isNullOrEmpty() -> PermalinkData.FallbackLink(uri)
|
||||
MatrixPatterns.isUserId(identifier) -> PermalinkData.UserLink(userId = identifier)
|
||||
MatrixPatterns.isGroupId(identifier) -> PermalinkData.GroupLink(groupId = identifier)
|
||||
MatrixPatterns.isRoomId(identifier) -> {
|
||||
handleRoomIdCase(fragment, identifier, matrixToUri, extraParameter, viaQueryParameters)
|
||||
}
|
||||
MatrixPatterns.isRoomAlias(identifier) -> {
|
||||
|
@ -81,7 +81,7 @@ object PermalinkParser {
|
|||
viaParameters = viaQueryParameters
|
||||
)
|
||||
}
|
||||
else -> PermalinkData.FallbackLink(uri)
|
||||
else -> PermalinkData.FallbackLink(uri)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,15 +71,15 @@ sealed class Action {
|
|||
fun List<Action>.toJson(): List<Any> {
|
||||
return map { action ->
|
||||
when (action) {
|
||||
is Action.Notify -> Action.ACTION_NOTIFY
|
||||
is Action.Notify -> Action.ACTION_NOTIFY
|
||||
is Action.DoNotNotify -> Action.ACTION_DONT_NOTIFY
|
||||
is Action.Sound -> {
|
||||
is Action.Sound -> {
|
||||
mapOf(
|
||||
Action.ACTION_OBJECT_SET_TWEAK_KEY to Action.ACTION_OBJECT_SET_TWEAK_VALUE_SOUND,
|
||||
Action.ACTION_OBJECT_VALUE_KEY to action.sound
|
||||
)
|
||||
}
|
||||
is Action.Highlight -> {
|
||||
is Action.Highlight -> {
|
||||
mapOf(
|
||||
Action.ACTION_OBJECT_SET_TWEAK_KEY to Action.ACTION_OBJECT_SET_TWEAK_VALUE_HIGHLIGHT,
|
||||
Action.ACTION_OBJECT_VALUE_KEY to action.highlight
|
||||
|
@ -94,11 +94,11 @@ fun PushRule.getActions(): List<Action> {
|
|||
|
||||
actions.forEach { actionStrOrObj ->
|
||||
when (actionStrOrObj) {
|
||||
Action.ACTION_NOTIFY -> Action.Notify
|
||||
Action.ACTION_NOTIFY -> Action.Notify
|
||||
Action.ACTION_DONT_NOTIFY -> Action.DoNotNotify
|
||||
is Map<*, *> -> {
|
||||
is Map<*, *> -> {
|
||||
when (actionStrOrObj[Action.ACTION_OBJECT_SET_TWEAK_KEY]) {
|
||||
Action.ACTION_OBJECT_SET_TWEAK_VALUE_SOUND -> {
|
||||
Action.ACTION_OBJECT_SET_TWEAK_VALUE_SOUND -> {
|
||||
(actionStrOrObj[Action.ACTION_OBJECT_VALUE_KEY] as? String)?.let { stringValue ->
|
||||
Action.Sound(stringValue)
|
||||
}
|
||||
|
@ -112,13 +112,13 @@ fun PushRule.getActions(): List<Action> {
|
|||
// When the value is not there, default is true, says the spec
|
||||
?: Action.Highlight(true)
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
Timber.w("Unsupported set_tweak value ${actionStrOrObj[Action.ACTION_OBJECT_SET_TWEAK_KEY]}")
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
Timber.w("Unsupported action type $actionStrOrObj")
|
||||
null
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class ContainsDisplayNameCondition : Condition {
|
|||
// EventType.ENCRYPTED -> {
|
||||
// event.root.getClearContent()?.toModel<MessageContent>()
|
||||
// }
|
||||
else -> null
|
||||
else -> null
|
||||
} ?: return false
|
||||
|
||||
return message.body.caseInsensitiveFind(displayName)
|
||||
|
|
|
@ -27,11 +27,11 @@ enum class Kind(val value: String) {
|
|||
|
||||
fun fromString(value: String): Kind {
|
||||
return when (value) {
|
||||
"event_match" -> EventMatch
|
||||
"contains_display_name" -> ContainsDisplayName
|
||||
"room_member_count" -> RoomMemberCount
|
||||
"event_match" -> EventMatch
|
||||
"contains_display_name" -> ContainsDisplayName
|
||||
"room_member_count" -> RoomMemberCount
|
||||
"sender_notification_permission" -> SenderNotificationPermission
|
||||
else -> Unrecognised
|
||||
else -> Unrecognised
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,8 +47,8 @@ class RoomMemberCountCondition(
|
|||
val numMembers = room.membershipService().getNumberOfJoinedMembers()
|
||||
|
||||
return when (prefix) {
|
||||
"<" -> numMembers < count
|
||||
">" -> numMembers > count
|
||||
"<" -> numMembers < count
|
||||
">" -> numMembers > count
|
||||
"<=" -> numMembers <= count
|
||||
">=" -> numMembers >= count
|
||||
else -> numMembers == count
|
||||
|
|
|
@ -61,7 +61,7 @@ data class PushCondition(
|
|||
|
||||
fun asExecutableCondition(rule: PushRule): Condition? {
|
||||
return when (Kind.fromString(kind)) {
|
||||
Kind.EventMatch -> {
|
||||
Kind.EventMatch -> {
|
||||
if (key != null && pattern != null) {
|
||||
EventMatchCondition(key, pattern, rule.ruleId == RuleIds.RULE_ID_CONTAIN_USER_NAME)
|
||||
} else {
|
||||
|
@ -69,10 +69,10 @@ data class PushCondition(
|
|||
null
|
||||
}
|
||||
}
|
||||
Kind.ContainsDisplayName -> {
|
||||
Kind.ContainsDisplayName -> {
|
||||
ContainsDisplayNameCondition()
|
||||
}
|
||||
Kind.RoomMemberCount -> {
|
||||
Kind.RoomMemberCount -> {
|
||||
if (iz.isNullOrEmpty()) {
|
||||
Timber.e("Malformed ROOM_MEMBER_COUNT condition")
|
||||
null
|
||||
|
@ -88,7 +88,7 @@ data class PushCondition(
|
|||
SenderNotificationPermissionCondition(key)
|
||||
}
|
||||
}
|
||||
Kind.Unrecognised -> {
|
||||
Kind.Unrecognised -> {
|
||||
Timber.e("Unknown kind $kind")
|
||||
null
|
||||
}
|
||||
|
|
|
@ -95,8 +95,8 @@ data class PowerLevelsContent(
|
|||
// the first implementation was a string value
|
||||
is String -> value.toInt()
|
||||
is Double -> value.toInt()
|
||||
is Int -> value
|
||||
else -> Role.Moderator.value
|
||||
is Int -> value
|
||||
else -> Role.Moderator.value
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,9 +30,9 @@ data class RoomGuestAccessContent(
|
|||
@Json(name = "guest_access") val guestAccessStr: String? = null
|
||||
) {
|
||||
val guestAccess: GuestAccess? = when (guestAccessStr) {
|
||||
"can_join" -> GuestAccess.CanJoin
|
||||
"can_join" -> GuestAccess.CanJoin
|
||||
"forbidden" -> GuestAccess.Forbidden
|
||||
else -> {
|
||||
else -> {
|
||||
Timber.w("Invalid value for GuestAccess: `$guestAccessStr`")
|
||||
null
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ data class RoomHistoryVisibilityContent(
|
|||
) {
|
||||
val historyVisibility: RoomHistoryVisibility? = when (historyVisibilityStr) {
|
||||
"world_readable" -> RoomHistoryVisibility.WORLD_READABLE
|
||||
"shared" -> RoomHistoryVisibility.SHARED
|
||||
"invited" -> RoomHistoryVisibility.INVITED
|
||||
"joined" -> RoomHistoryVisibility.JOINED
|
||||
else -> {
|
||||
"shared" -> RoomHistoryVisibility.SHARED
|
||||
"invited" -> RoomHistoryVisibility.INVITED
|
||||
"joined" -> RoomHistoryVisibility.JOINED
|
||||
else -> {
|
||||
Timber.w("Invalid value for RoomHistoryVisibility: `$historyVisibilityStr`")
|
||||
null
|
||||
}
|
||||
|
|
|
@ -36,12 +36,12 @@ data class RoomJoinRulesContent(
|
|||
@Json(name = "allow") val allowList: List<RoomJoinRulesAllowEntry>? = null
|
||||
) {
|
||||
val joinRules: RoomJoinRules? = when (joinRulesStr) {
|
||||
"public" -> RoomJoinRules.PUBLIC
|
||||
"invite" -> RoomJoinRules.INVITE
|
||||
"knock" -> RoomJoinRules.KNOCK
|
||||
"private" -> RoomJoinRules.PRIVATE
|
||||
"public" -> RoomJoinRules.PUBLIC
|
||||
"invite" -> RoomJoinRules.INVITE
|
||||
"knock" -> RoomJoinRules.KNOCK
|
||||
"private" -> RoomJoinRules.PRIVATE
|
||||
"restricted" -> RoomJoinRules.RESTRICTED
|
||||
else -> {
|
||||
else -> {
|
||||
Timber.w("Invalid value for RoomJoinRules: `$joinRulesStr`")
|
||||
null
|
||||
}
|
||||
|
|
|
@ -32,11 +32,11 @@ sealed class Role(open val value: Int) : Comparable<Role> {
|
|||
// Order matters, default value should be checked after defined roles
|
||||
fun fromValue(value: Int, default: Int): Role {
|
||||
return when (value) {
|
||||
Admin.value -> Admin
|
||||
Admin.value -> Admin
|
||||
Moderator.value -> Moderator
|
||||
Default.value,
|
||||
default -> Default
|
||||
else -> Custom(value)
|
||||
default -> Default
|
||||
else -> Custom(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ sealed interface UserDraft {
|
|||
fun isValid(): Boolean {
|
||||
return when (this) {
|
||||
is Regular -> content.isNotBlank()
|
||||
else -> true
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,9 @@ data class SenderInfo(
|
|||
) {
|
||||
val disambiguatedDisplayName: String
|
||||
get() = when {
|
||||
displayName == null -> userId
|
||||
displayName == null -> userId
|
||||
displayName.replaceSpaceChars().isBlank() -> "$displayName ($userId)"
|
||||
isUniqueDisplayName -> displayName
|
||||
else -> "$displayName ($userId)"
|
||||
isUniqueDisplayName -> displayName
|
||||
else -> "$displayName ($userId)"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,11 +139,11 @@ fun TimelineEvent.getEditedEventId(): String? {
|
|||
*/
|
||||
fun TimelineEvent.getLastMessageContent(): MessageContent? {
|
||||
return when (root.getClearType()) {
|
||||
EventType.STICKER -> root.getClearContent().toModel<MessageStickerContent>()
|
||||
in EventType.POLL_START -> (annotations?.editSummary?.latestContent ?: root.getClearContent()).toModel<MessagePollContent>()
|
||||
EventType.STICKER -> root.getClearContent().toModel<MessageStickerContent>()
|
||||
in EventType.POLL_START -> (annotations?.editSummary?.latestContent ?: root.getClearContent()).toModel<MessagePollContent>()
|
||||
in EventType.STATE_ROOM_BEACON_INFO -> (annotations?.editSummary?.latestContent ?: root.getClearContent()).toModel<MessageBeaconInfoContent>()
|
||||
in EventType.BEACON_LOCATION_DATA -> (annotations?.editSummary?.latestContent ?: root.getClearContent()).toModel<MessageBeaconLocationDataContent>()
|
||||
else -> (annotations?.editSummary?.latestContent ?: root.getClearContent()).toModel()
|
||||
in EventType.BEACON_LOCATION_DATA -> (annotations?.editSummary?.latestContent ?: root.getClearContent()).toModel<MessageBeaconLocationDataContent>()
|
||||
else -> (annotations?.editSummary?.latestContent ?: root.getClearContent()).toModel()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ abstract class SyncService : Service() {
|
|||
stopMe()
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
val isInit = initialize(intent)
|
||||
onStart(isInitialSync)
|
||||
if (isInit) {
|
||||
|
|
|
@ -138,20 +138,20 @@ sealed class MatrixItem(
|
|||
* Return the prefix as defined in the matrix spec (and not extracted from the id).
|
||||
*/
|
||||
private fun getIdPrefix() = when (this) {
|
||||
is UserItem -> '@'
|
||||
is EventItem -> '$'
|
||||
is UserItem -> '@'
|
||||
is EventItem -> '$'
|
||||
is SpaceItem,
|
||||
is RoomItem,
|
||||
is EveryoneInRoomItem -> '!'
|
||||
is RoomAliasItem -> '#'
|
||||
is GroupItem -> '+'
|
||||
is RoomAliasItem -> '#'
|
||||
is GroupItem -> '+'
|
||||
}
|
||||
|
||||
fun firstLetterOfDisplayName(): String {
|
||||
val displayName = when (this) {
|
||||
// use the room display name for the notify everyone item
|
||||
is EveryoneInRoomItem -> roomDisplayName
|
||||
else -> displayName
|
||||
else -> displayName
|
||||
}
|
||||
return (displayName?.takeIf { it.isNotBlank() } ?: id)
|
||||
.let { dn ->
|
||||
|
|
|
@ -290,7 +290,7 @@ internal class DefaultAuthenticationService @Inject constructor(
|
|||
|
||||
getLoginFlowResult(newAuthAPI, versions, wellknownResult.homeServerUrl)
|
||||
}
|
||||
else -> throw Failure.OtherServerError("", HttpsURLConnection.HTTP_NOT_FOUND /* 404 */)
|
||||
else -> throw Failure.OtherServerError("", HttpsURLConnection.HTTP_NOT_FOUND /* 404 */)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ internal class DefaultDirectLoginTask @Inject constructor(
|
|||
homeServerUrl,
|
||||
throwable.fingerprint
|
||||
)
|
||||
else -> throwable
|
||||
else -> throwable
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ internal data class AddThreePidRegistrationParams(
|
|||
companion object {
|
||||
fun from(params: RegisterAddThreePidTask.Params): AddThreePidRegistrationParams {
|
||||
return when (params.threePid) {
|
||||
is RegisterThreePid.Email -> AddThreePidRegistrationParams(
|
||||
is RegisterThreePid.Email -> AddThreePidRegistrationParams(
|
||||
email = params.threePid.email,
|
||||
clientSecret = params.clientSecret,
|
||||
sendAttempt = params.sendAttempt
|
||||
|
|
|
@ -52,12 +52,12 @@ internal class DefaultRegistrationWizard(
|
|||
override val currentThreePid: String?
|
||||
get() {
|
||||
return when (val threePid = pendingSessionData.currentThreePidData?.threePid) {
|
||||
is RegisterThreePid.Email -> threePid.email
|
||||
is RegisterThreePid.Email -> threePid.email
|
||||
is RegisterThreePid.Msisdn -> {
|
||||
// Take formatted msisdn if provided by the server
|
||||
pendingSessionData.currentThreePidData?.addThreePidRegistrationResponse?.formattedMsisdn?.takeIf { it.isNotBlank() } ?: threePid.msisdn
|
||||
}
|
||||
null -> null
|
||||
null -> null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ internal class DefaultRegisterAddThreePidTask(
|
|||
|
||||
private fun RegisterThreePid.toPath(): String {
|
||||
return when (this) {
|
||||
is RegisterThreePid.Email -> "email"
|
||||
is RegisterThreePid.Email -> "email"
|
||||
is RegisterThreePid.Msisdn -> "msisdn"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ internal data class ThreePidData(
|
|||
registrationParams: RegistrationParams
|
||||
): ThreePidData {
|
||||
return when (threePid) {
|
||||
is RegisterThreePid.Email ->
|
||||
is RegisterThreePid.Email ->
|
||||
ThreePidData(threePid.email, "", "", addThreePidRegistrationResponse, registrationParams)
|
||||
is RegisterThreePid.Msisdn ->
|
||||
ThreePidData("", threePid.msisdn, threePid.countryCode, addThreePidRegistrationResponse, registrationParams)
|
||||
|
|
|
@ -33,7 +33,7 @@ internal data class HomeServerVersion(
|
|||
minor < other.minor -> -1
|
||||
patch > other.patch -> 1
|
||||
patch < other.patch -> -1
|
||||
else -> 0
|
||||
else -> 0
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -188,8 +188,8 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
|
||||
fun onStateEvent(roomId: String, event: Event) {
|
||||
when (event.type) {
|
||||
EventType.STATE_ROOM_ENCRYPTION -> onRoomEncryptionEvent(roomId, event)
|
||||
EventType.STATE_ROOM_MEMBER -> onRoomMembershipEvent(roomId, event)
|
||||
EventType.STATE_ROOM_ENCRYPTION -> onRoomEncryptionEvent(roomId, event)
|
||||
EventType.STATE_ROOM_MEMBER -> onRoomMembershipEvent(roomId, event)
|
||||
EventType.STATE_ROOM_HISTORY_VISIBILITY -> onRoomHistoryVisibilityEvent(roomId, event)
|
||||
}
|
||||
}
|
||||
|
@ -198,8 +198,8 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
// handle state events
|
||||
if (event.isStateEvent()) {
|
||||
when (event.type) {
|
||||
EventType.STATE_ROOM_ENCRYPTION -> onRoomEncryptionEvent(roomId, event)
|
||||
EventType.STATE_ROOM_MEMBER -> onRoomMembershipEvent(roomId, event)
|
||||
EventType.STATE_ROOM_ENCRYPTION -> onRoomEncryptionEvent(roomId, event)
|
||||
EventType.STATE_ROOM_MEMBER -> onRoomMembershipEvent(roomId, event)
|
||||
EventType.STATE_ROOM_HISTORY_VISIBILITY -> onRoomHistoryVisibilityEvent(roomId, event)
|
||||
}
|
||||
}
|
||||
|
@ -620,8 +620,8 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
|
||||
val alg: IMXEncrypting? = when (algorithm) {
|
||||
MXCRYPTO_ALGORITHM_MEGOLM -> megolmEncryptionFactory.create(roomId)
|
||||
MXCRYPTO_ALGORITHM_OLM -> olmEncryptionFactory.create(roomId)
|
||||
else -> null
|
||||
MXCRYPTO_ALGORITHM_OLM -> olmEncryptionFactory.create(roomId)
|
||||
else -> null
|
||||
}
|
||||
|
||||
if (alg != null) {
|
||||
|
@ -800,10 +800,10 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
// Keys are imported directly, not waiting for end of sync
|
||||
onRoomKeyEvent(event)
|
||||
}
|
||||
EventType.REQUEST_SECRET -> {
|
||||
EventType.REQUEST_SECRET -> {
|
||||
secretShareManager.handleSecretRequest(event)
|
||||
}
|
||||
EventType.ROOM_KEY_REQUEST -> {
|
||||
EventType.ROOM_KEY_REQUEST -> {
|
||||
event.getClearContent().toModel<RoomKeyShareRequest>()?.let { req ->
|
||||
// We'll always get these because we send room key requests to
|
||||
// '*' (ie. 'all devices') which includes the sending device,
|
||||
|
@ -815,13 +815,13 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
EventType.SEND_SECRET -> {
|
||||
EventType.SEND_SECRET -> {
|
||||
onSecretSendReceived(event)
|
||||
}
|
||||
EventType.ROOM_KEY_WITHHELD -> {
|
||||
EventType.ROOM_KEY_WITHHELD -> {
|
||||
onKeyWithHeldReceived(event)
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
@ -888,7 +888,7 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
secretValue: String
|
||||
): Boolean {
|
||||
return when (secretName) {
|
||||
MASTER_KEY_SSSS_NAME -> {
|
||||
MASTER_KEY_SSSS_NAME -> {
|
||||
crossSigningService.onSecretMSKGossip(secretValue)
|
||||
true
|
||||
}
|
||||
|
@ -904,7 +904,7 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
keysBackupService.onSecretKeyGossip(secretValue)
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -231,8 +231,8 @@ internal class DeviceListManager @Inject constructor(
|
|||
for ((k, value) in failures) {
|
||||
val statusCode = when (val status = value["status"]) {
|
||||
is Double -> status.toInt()
|
||||
is Int -> status.toInt()
|
||||
else -> 0
|
||||
is Int -> status.toInt()
|
||||
else -> 0
|
||||
}
|
||||
if (statusCode == 503) {
|
||||
synchronized(notReadyToRetryHS) {
|
||||
|
|
|
@ -135,7 +135,7 @@ internal class IncomingKeyRequestManager @Inject constructor(
|
|||
// just add to the buffer
|
||||
incomingRequestBuffer.add(validMegolmRequest)
|
||||
}
|
||||
MegolmRequestAction.Cancel -> {
|
||||
MegolmRequestAction.Cancel -> {
|
||||
// ignore, we can't cancel as it's not known (probably already processed)
|
||||
// still notify app layer if it was passed up previously
|
||||
IncomingRoomKeyRequest.fromRestRequest(senderId, request, clock)?.let { iReq ->
|
||||
|
@ -159,7 +159,7 @@ internal class IncomingKeyRequestManager @Inject constructor(
|
|||
MegolmRequestAction.Request -> {
|
||||
// it's already in buffer, nop keep existing
|
||||
}
|
||||
MegolmRequestAction.Cancel -> {
|
||||
MegolmRequestAction.Cancel -> {
|
||||
// discard the request in buffer
|
||||
incomingRequestBuffer.remove(existing)
|
||||
outgoingRequestScope.launch(coroutineDispatchers.computation) {
|
||||
|
|
|
@ -32,7 +32,7 @@ internal object MXCryptoAlgorithms {
|
|||
return when (algorithm) {
|
||||
MXCRYPTO_ALGORITHM_MEGOLM,
|
||||
MXCRYPTO_ALGORITHM_OLM -> true
|
||||
else -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ internal object MXCryptoAlgorithms {
|
|||
return when (algorithm) {
|
||||
MXCRYPTO_ALGORITHM_MEGOLM,
|
||||
MXCRYPTO_ALGORITHM_OLM -> true
|
||||
else -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -299,19 +299,19 @@ internal class OutgoingKeyRequestManager @Inject constructor(
|
|||
}
|
||||
knownRequest.forEach { request ->
|
||||
when (request.state) {
|
||||
OutgoingRoomKeyRequestState.UNSENT -> {
|
||||
OutgoingRoomKeyRequestState.UNSENT -> {
|
||||
if (request.fromIndex >= localKnownChainIndex) {
|
||||
// we have a good index we can cancel
|
||||
cryptoStore.deleteOutgoingRoomKeyRequest(request.requestId)
|
||||
}
|
||||
}
|
||||
OutgoingRoomKeyRequestState.SENT -> {
|
||||
OutgoingRoomKeyRequestState.SENT -> {
|
||||
// It was already sent, and index satisfied we can cancel
|
||||
if (request.fromIndex >= localKnownChainIndex) {
|
||||
cryptoStore.updateOutgoingRoomKeyRequestState(request.requestId, OutgoingRoomKeyRequestState.CANCELLATION_PENDING)
|
||||
}
|
||||
}
|
||||
OutgoingRoomKeyRequestState.CANCELLATION_PENDING -> {
|
||||
OutgoingRoomKeyRequestState.CANCELLATION_PENDING -> {
|
||||
// It is already marked to be cancelled
|
||||
}
|
||||
OutgoingRoomKeyRequestState.CANCELLATION_PENDING_AND_WILL_RESEND -> {
|
||||
|
@ -320,7 +320,7 @@ internal class OutgoingKeyRequestManager @Inject constructor(
|
|||
cryptoStore.updateOutgoingRoomKeyRequestState(request.requestId, OutgoingRoomKeyRequestState.CANCELLATION_PENDING)
|
||||
}
|
||||
}
|
||||
OutgoingRoomKeyRequestState.SENT_THEN_CANCELED -> {
|
||||
OutgoingRoomKeyRequestState.SENT_THEN_CANCELED -> {
|
||||
// was already canceled
|
||||
// if we need a better index, should we resend?
|
||||
}
|
||||
|
@ -351,14 +351,14 @@ internal class OutgoingKeyRequestManager @Inject constructor(
|
|||
val existing = cryptoStore.getOutgoingRoomKeyRequest(requestBody)
|
||||
Timber.tag(loggerTag.value).v("Queueing key request exiting is ${existing?.state}")
|
||||
when (existing?.state) {
|
||||
null -> {
|
||||
null -> {
|
||||
// create a new one
|
||||
cryptoStore.getOrAddOutgoingRoomKeyRequest(requestBody, recipients, fromIndex)
|
||||
}
|
||||
OutgoingRoomKeyRequestState.UNSENT -> {
|
||||
OutgoingRoomKeyRequestState.UNSENT -> {
|
||||
// nothing it's new or not yet handled
|
||||
}
|
||||
OutgoingRoomKeyRequestState.SENT -> {
|
||||
OutgoingRoomKeyRequestState.SENT -> {
|
||||
// it was already requested
|
||||
Timber.tag(loggerTag.value).d("The session ${requestBody.sessionId} is already requested")
|
||||
if (force) {
|
||||
|
@ -371,7 +371,7 @@ internal class OutgoingKeyRequestManager @Inject constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
OutgoingRoomKeyRequestState.CANCELLATION_PENDING -> {
|
||||
OutgoingRoomKeyRequestState.CANCELLATION_PENDING -> {
|
||||
// request is canceled only if I got the keys so what to do here...
|
||||
if (force) {
|
||||
cryptoStore.updateOutgoingRoomKeyRequestState(existing.requestId, OutgoingRoomKeyRequestState.CANCELLATION_PENDING_AND_WILL_RESEND)
|
||||
|
@ -380,7 +380,7 @@ internal class OutgoingKeyRequestManager @Inject constructor(
|
|||
OutgoingRoomKeyRequestState.CANCELLATION_PENDING_AND_WILL_RESEND -> {
|
||||
// It's already going to resend
|
||||
}
|
||||
OutgoingRoomKeyRequestState.SENT_THEN_CANCELED -> {
|
||||
OutgoingRoomKeyRequestState.SENT_THEN_CANCELED -> {
|
||||
if (force) {
|
||||
cryptoStore.deleteOutgoingRoomKeyRequest(existing.requestId)
|
||||
cryptoStore.getOrAddOutgoingRoomKeyRequest(requestBody, recipients, fromIndex)
|
||||
|
@ -401,11 +401,11 @@ internal class OutgoingKeyRequestManager @Inject constructor(
|
|||
measureTimeMillis {
|
||||
toProcess.forEach {
|
||||
when (it.state) {
|
||||
OutgoingRoomKeyRequestState.UNSENT -> handleUnsentRequest(it)
|
||||
OutgoingRoomKeyRequestState.CANCELLATION_PENDING -> handleRequestToCancel(it)
|
||||
OutgoingRoomKeyRequestState.UNSENT -> handleUnsentRequest(it)
|
||||
OutgoingRoomKeyRequestState.CANCELLATION_PENDING -> handleRequestToCancel(it)
|
||||
OutgoingRoomKeyRequestState.CANCELLATION_PENDING_AND_WILL_RESEND -> handleRequestToCancelWillResend(it)
|
||||
OutgoingRoomKeyRequestState.SENT_THEN_CANCELED,
|
||||
OutgoingRoomKeyRequestState.SENT -> {
|
||||
OutgoingRoomKeyRequestState.SENT -> {
|
||||
// these are filtered out
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ internal class RoomDecryptorProvider @Inject constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
else -> olmDecryptionFactory.create()
|
||||
else -> olmDecryptionFactory.create()
|
||||
}
|
||||
if (!roomId.isNullOrEmpty()) {
|
||||
synchronized(roomDecryptors) {
|
||||
|
|
|
@ -49,8 +49,8 @@ internal class RoomEncryptorsStore @Inject constructor(
|
|||
} else {
|
||||
val alg: IMXEncrypting? = when (cryptoStore.getRoomAlgorithm(roomId)) {
|
||||
MXCRYPTO_ALGORITHM_MEGOLM -> megolmEncryptionFactory.create(roomId)
|
||||
MXCRYPTO_ALGORITHM_OLM -> olmEncryptionFactory.create(roomId)
|
||||
else -> null
|
||||
MXCRYPTO_ALGORITHM_OLM -> olmEncryptionFactory.create(roomId)
|
||||
else -> null
|
||||
}
|
||||
alg?.let { roomEncryptors.put(roomId, it) }
|
||||
return@synchronized alg
|
||||
|
|
|
@ -150,14 +150,14 @@ internal class SecretShareManager @Inject constructor(
|
|||
// we can share the secret
|
||||
|
||||
val secretValue = when (secretName) {
|
||||
MASTER_KEY_SSSS_NAME -> cryptoStore.getCrossSigningPrivateKeys()?.master
|
||||
MASTER_KEY_SSSS_NAME -> cryptoStore.getCrossSigningPrivateKeys()?.master
|
||||
SELF_SIGNING_KEY_SSSS_NAME -> cryptoStore.getCrossSigningPrivateKeys()?.selfSigned
|
||||
USER_SIGNING_KEY_SSSS_NAME -> cryptoStore.getCrossSigningPrivateKeys()?.user
|
||||
KEYBACKUP_SECRET_SSSS_NAME -> cryptoStore.getKeyBackupRecoveryKeyInfo()?.recoveryKey
|
||||
?.let {
|
||||
extractCurveKeyFromRecoveryKey(it)?.toBase64NoPadding()
|
||||
}
|
||||
else -> null
|
||||
else -> null
|
||||
}
|
||||
if (secretValue == null) {
|
||||
Timber.tag(loggerTag.value)
|
||||
|
|
|
@ -191,9 +191,9 @@ internal class MXOlmDecryption(
|
|||
val messageBody = message["body"] as? String ?: return null
|
||||
val messageType = when (val typeAsVoid = message["type"]) {
|
||||
is Double -> typeAsVoid.toInt()
|
||||
is Int -> typeAsVoid
|
||||
is Long -> typeAsVoid.toInt()
|
||||
else -> return null
|
||||
is Int -> typeAsVoid
|
||||
is Long -> typeAsVoid.toInt()
|
||||
else -> return null
|
||||
}
|
||||
|
||||
// Try each session in turn
|
||||
|
|
|
@ -53,13 +53,13 @@ internal class CrossSigningOlm @Inject constructor(
|
|||
fun signObject(type: KeyType, strToSign: String): Map<String, String> {
|
||||
val myKeys = cryptoStore.getMyCrossSigningInfo()
|
||||
val pubKey = when (type) {
|
||||
KeyType.SELF -> myKeys?.selfSigningKey()
|
||||
KeyType.USER -> myKeys?.userKey()
|
||||
KeyType.SELF -> myKeys?.selfSigningKey()
|
||||
KeyType.USER -> myKeys?.userKey()
|
||||
KeyType.MASTER -> myKeys?.masterKey()
|
||||
}?.unpaddedBase64PublicKey
|
||||
val pkSigning = when (type) {
|
||||
KeyType.SELF -> selfSigningPkSigning
|
||||
KeyType.USER -> userPkSigning
|
||||
KeyType.SELF -> selfSigningPkSigning
|
||||
KeyType.USER -> userPkSigning
|
||||
KeyType.MASTER -> masterPkSigning
|
||||
}
|
||||
if (pubKey == null || pkSigning == null) {
|
||||
|
@ -76,8 +76,8 @@ internal class CrossSigningOlm @Inject constructor(
|
|||
?: throw NoSuchElementException("Cross Signing not configured")
|
||||
val myUserID = myKeys.userId
|
||||
val pubKey = when (type) {
|
||||
KeyType.SELF -> myKeys.selfSigningKey()
|
||||
KeyType.USER -> myKeys.userKey()
|
||||
KeyType.SELF -> myKeys.selfSigningKey()
|
||||
KeyType.USER -> myKeys.userKey()
|
||||
KeyType.MASTER -> myKeys.masterKey()
|
||||
}?.unpaddedBase64PublicKey ?: throw NoSuchElementException("Cross Signing not configured")
|
||||
val signaturesMadeByMyKey = signatures[myUserID] // Signatures made by me
|
||||
|
|
|
@ -149,7 +149,7 @@ internal class UpdateTrustWorker(context: Context, params: WorkerParameters, ses
|
|||
val trusts = otherInfos.mapValues { entry ->
|
||||
when (entry.key) {
|
||||
myUserId -> myTrustResult
|
||||
else -> {
|
||||
else -> {
|
||||
crossSigningService.checkOtherMSKTrusted(myCrossSigningInfo, entry.value).also {
|
||||
Timber.v("## CrossSigning - user:${entry.key} result:$it")
|
||||
}
|
||||
|
|
|
@ -328,7 +328,7 @@ internal class DefaultKeysBackupService @Inject constructor(
|
|||
// val hashServer = keysBackupData?.backupLastServerHash
|
||||
|
||||
return when {
|
||||
totalNumberOfKeysLocally < totalNumberOfKeysServer -> {
|
||||
totalNumberOfKeysLocally < totalNumberOfKeysServer -> {
|
||||
// Server contains more keys than this device
|
||||
true
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ internal class DefaultKeysBackupService @Inject constructor(
|
|||
// TODO We have not found any algorithm to determine if a restore is recommended here. Return false for the moment
|
||||
false
|
||||
}
|
||||
else -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -935,7 +935,7 @@ internal class DefaultKeysBackupService @Inject constructor(
|
|||
*/
|
||||
fun maybeBackupKeys() {
|
||||
when {
|
||||
isStucked -> {
|
||||
isStucked -> {
|
||||
// If not already done, or in error case, check for a valid backup version on the homeserver.
|
||||
// If there is one, maybeBackupKeys will be called again.
|
||||
checkAndStartKeysBackup()
|
||||
|
@ -953,7 +953,7 @@ internal class DefaultKeysBackupService @Inject constructor(
|
|||
uiHandler.post { backupKeys() }
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
Timber.v("maybeBackupKeys: Skip it because state: $state")
|
||||
}
|
||||
}
|
||||
|
@ -998,7 +998,7 @@ internal class DefaultKeysBackupService @Inject constructor(
|
|||
override fun onSuccess(data: KeysBackupLastVersionResult) {
|
||||
val localBackupVersion = keysBackupVersion?.version
|
||||
when (data) {
|
||||
KeysBackupLastVersionResult.NoKeysBackup -> {
|
||||
KeysBackupLastVersionResult.NoKeysBackup -> {
|
||||
if (localBackupVersion == null) {
|
||||
// No backup on the server, and backup is not active
|
||||
callback.onSuccess(true)
|
||||
|
@ -1384,7 +1384,7 @@ internal class DefaultKeysBackupService @Inject constructor(
|
|||
// Do not stay in KeysBackupState.WrongBackUpVersion but check what is available on the homeserver
|
||||
checkAndStartKeysBackup()
|
||||
}
|
||||
else ->
|
||||
else ->
|
||||
// Come back to the ready state so that we will retry on the next received key
|
||||
keysBackupStateManager.state = KeysBackupState.ReadyToBackUp
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ internal const val VERIFICATION_METHOD_RECIPROCATE = "m.reciprocate.v1"
|
|||
|
||||
internal fun VerificationMethod.toValue(): String {
|
||||
return when (this) {
|
||||
VerificationMethod.SAS -> VERIFICATION_METHOD_SAS
|
||||
VerificationMethod.SAS -> VERIFICATION_METHOD_SAS
|
||||
VerificationMethod.QR_CODE_SCAN -> VERIFICATION_METHOD_QR_CODE_SCAN
|
||||
VerificationMethod.QR_CODE_SHOW -> VERIFICATION_METHOD_QR_CODE_SHOW
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ internal class DefaultSharedSecretStorageService @Inject constructor(
|
|||
throw SharedSecretStorageError.UnknownAlgorithm(key.keyInfo.content.algorithm ?: "")
|
||||
}
|
||||
}
|
||||
is KeyInfoResult.Error -> throw key.error
|
||||
is KeyInfoResult.Error -> throw key.error
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,10 +104,10 @@ internal class MigrateCryptoTo004(realm: DynamicRealm) : RealmMigrator(realm, 4)
|
|||
|
||||
val trustLevel = realm.createObject("TrustLevelEntity")
|
||||
when (oldDevice.verified) {
|
||||
MXDeviceInfo.DEVICE_VERIFICATION_UNKNOWN -> {
|
||||
MXDeviceInfo.DEVICE_VERIFICATION_UNKNOWN -> {
|
||||
obj.setNull(DeviceInfoEntityFields.TRUST_LEVEL_ENTITY.`$`)
|
||||
}
|
||||
MXDeviceInfo.DEVICE_VERIFICATION_BLOCKED -> {
|
||||
MXDeviceInfo.DEVICE_VERIFICATION_BLOCKED -> {
|
||||
trustLevel.setNull(TrustLevelEntityFields.LOCALLY_VERIFIED)
|
||||
trustLevel.setNull(TrustLevelEntityFields.CROSS_SIGNED_VERIFIED)
|
||||
obj.setBoolean(DeviceInfoEntityFields.IS_BLOCKED, oldDevice.isBlocked)
|
||||
|
@ -118,7 +118,7 @@ internal class MigrateCryptoTo004(realm: DynamicRealm) : RealmMigrator(realm, 4)
|
|||
trustLevel.setBoolean(TrustLevelEntityFields.CROSS_SIGNED_VERIFIED, false)
|
||||
obj.setObject(DeviceInfoEntityFields.TRUST_LEVEL_ENTITY.`$`, trustLevel)
|
||||
}
|
||||
MXDeviceInfo.DEVICE_VERIFICATION_VERIFIED -> {
|
||||
MXDeviceInfo.DEVICE_VERIFICATION_VERIFIED -> {
|
||||
trustLevel.setBoolean(TrustLevelEntityFields.LOCALLY_VERIFIED, true)
|
||||
trustLevel.setBoolean(TrustLevelEntityFields.CROSS_SIGNED_VERIFIED, false)
|
||||
obj.setObject(DeviceInfoEntityFields.TRUST_LEVEL_ENTITY.`$`, trustLevel)
|
||||
|
|
|
@ -30,7 +30,7 @@ internal object AuditTrailMapper {
|
|||
fun map(entity: AuditTrailEntity): AuditTrail? {
|
||||
val contentJson = entity.contentJson ?: return null
|
||||
return when (entity.type) {
|
||||
TrailType.OutgoingKeyForward.name -> {
|
||||
TrailType.OutgoingKeyForward.name -> {
|
||||
val info = tryOrNull {
|
||||
MoshiProvider.providesMoshi().adapter(ForwardInfo::class.java).fromJson(contentJson)
|
||||
} ?: return null
|
||||
|
@ -50,7 +50,7 @@ internal object AuditTrailMapper {
|
|||
info = info
|
||||
)
|
||||
}
|
||||
TrailType.IncomingKeyRequest.name -> {
|
||||
TrailType.IncomingKeyRequest.name -> {
|
||||
val info = tryOrNull {
|
||||
MoshiProvider.providesMoshi().adapter(IncomingKeyRequestInfo::class.java).fromJson(contentJson)
|
||||
} ?: return null
|
||||
|
@ -60,7 +60,7 @@ internal object AuditTrailMapper {
|
|||
info = info
|
||||
)
|
||||
}
|
||||
TrailType.IncomingKeyForward.name -> {
|
||||
TrailType.IncomingKeyForward.name -> {
|
||||
val info = tryOrNull {
|
||||
MoshiProvider.providesMoshi().adapter(ForwardInfo::class.java).fromJson(contentJson)
|
||||
} ?: return null
|
||||
|
@ -70,7 +70,7 @@ internal object AuditTrailMapper {
|
|||
info = info
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
AuditTrail(
|
||||
ageLocalTs = entity.ageLocalTs ?: 0,
|
||||
type = TrailType.Unknown,
|
||||
|
|
|
@ -60,26 +60,26 @@ internal class DefaultIncomingSASDefaultVerificationTransaction(
|
|||
override val uxState: IncomingSasVerificationTransaction.UxState
|
||||
get() {
|
||||
return when (val immutableState = state) {
|
||||
is VerificationTxState.OnStarted -> IncomingSasVerificationTransaction.UxState.SHOW_ACCEPT
|
||||
is VerificationTxState.OnStarted -> IncomingSasVerificationTransaction.UxState.SHOW_ACCEPT
|
||||
is VerificationTxState.SendingAccept,
|
||||
is VerificationTxState.Accepted,
|
||||
is VerificationTxState.OnKeyReceived,
|
||||
is VerificationTxState.SendingKey,
|
||||
is VerificationTxState.KeySent -> IncomingSasVerificationTransaction.UxState.WAIT_FOR_KEY_AGREEMENT
|
||||
is VerificationTxState.KeySent -> IncomingSasVerificationTransaction.UxState.WAIT_FOR_KEY_AGREEMENT
|
||||
is VerificationTxState.ShortCodeReady -> IncomingSasVerificationTransaction.UxState.SHOW_SAS
|
||||
is VerificationTxState.ShortCodeAccepted,
|
||||
is VerificationTxState.SendingMac,
|
||||
is VerificationTxState.MacSent,
|
||||
is VerificationTxState.Verifying -> IncomingSasVerificationTransaction.UxState.WAIT_FOR_VERIFICATION
|
||||
is VerificationTxState.Verified -> IncomingSasVerificationTransaction.UxState.VERIFIED
|
||||
is VerificationTxState.Cancelled -> {
|
||||
is VerificationTxState.Verifying -> IncomingSasVerificationTransaction.UxState.WAIT_FOR_VERIFICATION
|
||||
is VerificationTxState.Verified -> IncomingSasVerificationTransaction.UxState.VERIFIED
|
||||
is VerificationTxState.Cancelled -> {
|
||||
if (immutableState.byMe) {
|
||||
IncomingSasVerificationTransaction.UxState.CANCELLED_BY_ME
|
||||
} else {
|
||||
IncomingSasVerificationTransaction.UxState.CANCELLED_BY_OTHER
|
||||
}
|
||||
}
|
||||
else -> IncomingSasVerificationTransaction.UxState.UNKNOWN
|
||||
else -> IncomingSasVerificationTransaction.UxState.UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,7 @@ internal class DefaultIncomingSASDefaultVerificationTransaction(
|
|||
val sasInfo = "MATRIX_KEY_VERIFICATION_SAS|$otherUserId|$otherDeviceId|$otherKey|$userId|$deviceId|${getSAS().publicKey}|$transactionId"
|
||||
return getSAS().generateShortCode(sasInfo, 6)
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
// Protocol has been checked earlier
|
||||
throw IllegalArgumentException()
|
||||
}
|
||||
|
|
|
@ -57,27 +57,27 @@ internal class DefaultOutgoingSASDefaultVerificationTransaction(
|
|||
override val uxState: OutgoingSasVerificationTransaction.UxState
|
||||
get() {
|
||||
return when (val immutableState = state) {
|
||||
is VerificationTxState.None -> OutgoingSasVerificationTransaction.UxState.WAIT_FOR_START
|
||||
is VerificationTxState.None -> OutgoingSasVerificationTransaction.UxState.WAIT_FOR_START
|
||||
is VerificationTxState.SendingStart,
|
||||
is VerificationTxState.Started,
|
||||
is VerificationTxState.OnAccepted,
|
||||
is VerificationTxState.SendingKey,
|
||||
is VerificationTxState.KeySent,
|
||||
is VerificationTxState.OnKeyReceived -> OutgoingSasVerificationTransaction.UxState.WAIT_FOR_KEY_AGREEMENT
|
||||
is VerificationTxState.OnKeyReceived -> OutgoingSasVerificationTransaction.UxState.WAIT_FOR_KEY_AGREEMENT
|
||||
is VerificationTxState.ShortCodeReady -> OutgoingSasVerificationTransaction.UxState.SHOW_SAS
|
||||
is VerificationTxState.ShortCodeAccepted,
|
||||
is VerificationTxState.SendingMac,
|
||||
is VerificationTxState.MacSent,
|
||||
is VerificationTxState.Verifying -> OutgoingSasVerificationTransaction.UxState.WAIT_FOR_VERIFICATION
|
||||
is VerificationTxState.Verified -> OutgoingSasVerificationTransaction.UxState.VERIFIED
|
||||
is VerificationTxState.Cancelled -> {
|
||||
is VerificationTxState.Verifying -> OutgoingSasVerificationTransaction.UxState.WAIT_FOR_VERIFICATION
|
||||
is VerificationTxState.Verified -> OutgoingSasVerificationTransaction.UxState.VERIFIED
|
||||
is VerificationTxState.Cancelled -> {
|
||||
if (immutableState.byMe) {
|
||||
OutgoingSasVerificationTransaction.UxState.CANCELLED_BY_OTHER
|
||||
} else {
|
||||
OutgoingSasVerificationTransaction.UxState.CANCELLED_BY_ME
|
||||
}
|
||||
}
|
||||
else -> OutgoingSasVerificationTransaction.UxState.UNKNOWN
|
||||
else -> OutgoingSasVerificationTransaction.UxState.UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ internal class DefaultOutgoingSASDefaultVerificationTransaction(
|
|||
val sasInfo = "MATRIX_KEY_VERIFICATION_SAS|$userId|$deviceId|${getSAS().publicKey}|$otherUserId|$otherDeviceId|$otherKey|$transactionId"
|
||||
return getSAS().generateShortCode(sasInfo, 6)
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
// Protocol has been checked earlier
|
||||
throw IllegalArgumentException()
|
||||
}
|
||||
|
|
|
@ -129,31 +129,31 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
Timber.d("## SAS onToDeviceEvent ${event.getClearType()}")
|
||||
cryptoCoroutineScope.launch(coroutineDispatchers.dmVerif) {
|
||||
when (event.getClearType()) {
|
||||
EventType.KEY_VERIFICATION_START -> {
|
||||
EventType.KEY_VERIFICATION_START -> {
|
||||
onStartRequestReceived(event)
|
||||
}
|
||||
EventType.KEY_VERIFICATION_CANCEL -> {
|
||||
EventType.KEY_VERIFICATION_CANCEL -> {
|
||||
onCancelReceived(event)
|
||||
}
|
||||
EventType.KEY_VERIFICATION_ACCEPT -> {
|
||||
EventType.KEY_VERIFICATION_ACCEPT -> {
|
||||
onAcceptReceived(event)
|
||||
}
|
||||
EventType.KEY_VERIFICATION_KEY -> {
|
||||
EventType.KEY_VERIFICATION_KEY -> {
|
||||
onKeyReceived(event)
|
||||
}
|
||||
EventType.KEY_VERIFICATION_MAC -> {
|
||||
EventType.KEY_VERIFICATION_MAC -> {
|
||||
onMacReceived(event)
|
||||
}
|
||||
EventType.KEY_VERIFICATION_READY -> {
|
||||
EventType.KEY_VERIFICATION_READY -> {
|
||||
onReadyReceived(event)
|
||||
}
|
||||
EventType.KEY_VERIFICATION_DONE -> {
|
||||
EventType.KEY_VERIFICATION_DONE -> {
|
||||
onDoneReceived(event)
|
||||
}
|
||||
MessageType.MSGTYPE_VERIFICATION_REQUEST -> {
|
||||
onRequestReceived(event)
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
fun onRoomEvent(event: Event) {
|
||||
cryptoCoroutineScope.launch(coroutineDispatchers.dmVerif) {
|
||||
when (event.getClearType()) {
|
||||
EventType.KEY_VERIFICATION_START -> {
|
||||
EventType.KEY_VERIFICATION_START -> {
|
||||
onRoomStartRequestReceived(event)
|
||||
}
|
||||
EventType.KEY_VERIFICATION_CANCEL -> {
|
||||
|
@ -173,24 +173,24 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
EventType.KEY_VERIFICATION_ACCEPT -> {
|
||||
onRoomAcceptReceived(event)
|
||||
}
|
||||
EventType.KEY_VERIFICATION_KEY -> {
|
||||
EventType.KEY_VERIFICATION_KEY -> {
|
||||
onRoomKeyRequestReceived(event)
|
||||
}
|
||||
EventType.KEY_VERIFICATION_MAC -> {
|
||||
EventType.KEY_VERIFICATION_MAC -> {
|
||||
onRoomMacReceived(event)
|
||||
}
|
||||
EventType.KEY_VERIFICATION_READY -> {
|
||||
EventType.KEY_VERIFICATION_READY -> {
|
||||
onRoomReadyReceived(event)
|
||||
}
|
||||
EventType.KEY_VERIFICATION_DONE -> {
|
||||
EventType.KEY_VERIFICATION_DONE -> {
|
||||
onRoomDoneReceived(event)
|
||||
}
|
||||
EventType.MESSAGE -> {
|
||||
EventType.MESSAGE -> {
|
||||
if (MessageType.MSGTYPE_VERIFICATION_REQUEST == event.getClearContent().toModel<MessageContent>()?.msgType) {
|
||||
onRoomRequestReceived(event)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
@ -507,9 +507,9 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
}
|
||||
|
||||
when (startReq) {
|
||||
is ValidVerificationInfoStart.SasVerificationInfoStart -> {
|
||||
is ValidVerificationInfoStart.SasVerificationInfoStart -> {
|
||||
when (existing) {
|
||||
is SasVerificationTransaction -> {
|
||||
is SasVerificationTransaction -> {
|
||||
// should cancel both!
|
||||
Timber.v("## SAS onStartRequestReceived - Request exist with same id ${startReq.transactionId}")
|
||||
existing.cancel(CancelCode.UnexpectedMessage)
|
||||
|
@ -519,7 +519,7 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
is QrCodeVerificationTransaction -> {
|
||||
// Nothing to do?
|
||||
}
|
||||
null -> {
|
||||
null -> {
|
||||
getExistingTransactionsForUser(otherUserId)
|
||||
?.filterIsInstance(SasVerificationTransaction::class.java)
|
||||
?.takeIf { it.isNotEmpty() }
|
||||
|
@ -973,12 +973,12 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
}
|
||||
|
||||
return when {
|
||||
userId != otherUserId ->
|
||||
userId != otherUserId ->
|
||||
createQrCodeDataForDistinctUser(requestId, otherUserId)
|
||||
crossSigningService.isCrossSigningVerified() ->
|
||||
// This is a self verification and I am the old device (Osborne2)
|
||||
createQrCodeDataForVerifiedDevice(requestId, otherDeviceId)
|
||||
else ->
|
||||
else ->
|
||||
// This is a self verification and I am the new device (Dynabook)
|
||||
createQrCodeDataForUnVerifiedDevice(requestId)
|
||||
}
|
||||
|
|
|
@ -333,11 +333,11 @@ internal abstract class SASDefaultVerificationTransaction(
|
|||
if (shortCodeBytes!!.size < 5) return null
|
||||
return getDecimalCodeRepresentation(shortCodeBytes!!)
|
||||
}
|
||||
SasMode.EMOJI -> {
|
||||
SasMode.EMOJI -> {
|
||||
if (shortCodeBytes!!.size < 6) return null
|
||||
return getEmojiCodeRepresentation(shortCodeBytes!!).joinToString(" ") { it.emoji }
|
||||
}
|
||||
else -> return null
|
||||
else -> return null
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -362,8 +362,8 @@ internal abstract class SASDefaultVerificationTransaction(
|
|||
private fun macUsingAgreedMethod(message: String, info: String): String? {
|
||||
return when (accepted?.messageAuthenticationCode?.lowercase(Locale.ROOT)) {
|
||||
SAS_MAC_SHA256_LONGKDF -> getSAS().calculateMacLongKdf(message, info)
|
||||
SAS_MAC_SHA256 -> getSAS().calculateMac(message, info)
|
||||
else -> null
|
||||
SAS_MAC_SHA256 -> getSAS().calculateMac(message, info)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,69 +20,69 @@ import org.matrix.android.sdk.api.session.crypto.verification.EmojiRepresentatio
|
|||
|
||||
internal fun getEmojiForCode(code: Int): EmojiRepresentation {
|
||||
return when (code % 64) {
|
||||
0 -> EmojiRepresentation("🐶", R.string.verification_emoji_dog, R.drawable.ic_verification_dog)
|
||||
1 -> EmojiRepresentation("🐱", R.string.verification_emoji_cat, R.drawable.ic_verification_cat)
|
||||
2 -> EmojiRepresentation("🦁", R.string.verification_emoji_lion, R.drawable.ic_verification_lion)
|
||||
3 -> EmojiRepresentation("🐎", R.string.verification_emoji_horse, R.drawable.ic_verification_horse)
|
||||
4 -> EmojiRepresentation("🦄", R.string.verification_emoji_unicorn, R.drawable.ic_verification_unicorn)
|
||||
5 -> EmojiRepresentation("🐷", R.string.verification_emoji_pig, R.drawable.ic_verification_pig)
|
||||
6 -> EmojiRepresentation("🐘", R.string.verification_emoji_elephant, R.drawable.ic_verification_elephant)
|
||||
7 -> EmojiRepresentation("🐰", R.string.verification_emoji_rabbit, R.drawable.ic_verification_rabbit)
|
||||
8 -> EmojiRepresentation("🐼", R.string.verification_emoji_panda, R.drawable.ic_verification_panda)
|
||||
9 -> EmojiRepresentation("🐓", R.string.verification_emoji_rooster, R.drawable.ic_verification_rooster)
|
||||
10 -> EmojiRepresentation("🐧", R.string.verification_emoji_penguin, R.drawable.ic_verification_penguin)
|
||||
11 -> EmojiRepresentation("🐢", R.string.verification_emoji_turtle, R.drawable.ic_verification_turtle)
|
||||
12 -> EmojiRepresentation("🐟", R.string.verification_emoji_fish, R.drawable.ic_verification_fish)
|
||||
13 -> EmojiRepresentation("🐙", R.string.verification_emoji_octopus, R.drawable.ic_verification_octopus)
|
||||
14 -> EmojiRepresentation("🦋", R.string.verification_emoji_butterfly, R.drawable.ic_verification_butterfly)
|
||||
15 -> EmojiRepresentation("🌷", R.string.verification_emoji_flower, R.drawable.ic_verification_flower)
|
||||
16 -> EmojiRepresentation("🌳", R.string.verification_emoji_tree, R.drawable.ic_verification_tree)
|
||||
17 -> EmojiRepresentation("🌵", R.string.verification_emoji_cactus, R.drawable.ic_verification_cactus)
|
||||
18 -> EmojiRepresentation("🍄", R.string.verification_emoji_mushroom, R.drawable.ic_verification_mushroom)
|
||||
19 -> EmojiRepresentation("🌏", R.string.verification_emoji_globe, R.drawable.ic_verification_globe)
|
||||
20 -> EmojiRepresentation("🌙", R.string.verification_emoji_moon, R.drawable.ic_verification_moon)
|
||||
21 -> EmojiRepresentation("☁️", R.string.verification_emoji_cloud, R.drawable.ic_verification_cloud)
|
||||
22 -> EmojiRepresentation("🔥", R.string.verification_emoji_fire, R.drawable.ic_verification_fire)
|
||||
23 -> EmojiRepresentation("🍌", R.string.verification_emoji_banana, R.drawable.ic_verification_banana)
|
||||
24 -> EmojiRepresentation("🍎", R.string.verification_emoji_apple, R.drawable.ic_verification_apple)
|
||||
25 -> EmojiRepresentation("🍓", R.string.verification_emoji_strawberry, R.drawable.ic_verification_strawberry)
|
||||
26 -> EmojiRepresentation("🌽", R.string.verification_emoji_corn, R.drawable.ic_verification_corn)
|
||||
27 -> EmojiRepresentation("🍕", R.string.verification_emoji_pizza, R.drawable.ic_verification_pizza)
|
||||
28 -> EmojiRepresentation("🎂", R.string.verification_emoji_cake, R.drawable.ic_verification_cake)
|
||||
29 -> EmojiRepresentation("❤️", R.string.verification_emoji_heart, R.drawable.ic_verification_heart)
|
||||
30 -> EmojiRepresentation("🙂", R.string.verification_emoji_smiley, R.drawable.ic_verification_smiley)
|
||||
31 -> EmojiRepresentation("🤖", R.string.verification_emoji_robot, R.drawable.ic_verification_robot)
|
||||
32 -> EmojiRepresentation("🎩", R.string.verification_emoji_hat, R.drawable.ic_verification_hat)
|
||||
33 -> EmojiRepresentation("👓", R.string.verification_emoji_glasses, R.drawable.ic_verification_glasses)
|
||||
34 -> EmojiRepresentation("🔧", R.string.verification_emoji_spanner, R.drawable.ic_verification_spanner)
|
||||
35 -> EmojiRepresentation("🎅", R.string.verification_emoji_santa, R.drawable.ic_verification_santa)
|
||||
36 -> EmojiRepresentation("👍", R.string.verification_emoji_thumbs_up, R.drawable.ic_verification_thumbs_up)
|
||||
37 -> EmojiRepresentation("☂️", R.string.verification_emoji_umbrella, R.drawable.ic_verification_umbrella)
|
||||
38 -> EmojiRepresentation("⌛", R.string.verification_emoji_hourglass, R.drawable.ic_verification_hourglass)
|
||||
39 -> EmojiRepresentation("⏰", R.string.verification_emoji_clock, R.drawable.ic_verification_clock)
|
||||
40 -> EmojiRepresentation("🎁", R.string.verification_emoji_gift, R.drawable.ic_verification_gift)
|
||||
41 -> EmojiRepresentation("💡", R.string.verification_emoji_light_bulb, R.drawable.ic_verification_light_bulb)
|
||||
42 -> EmojiRepresentation("📕", R.string.verification_emoji_book, R.drawable.ic_verification_book)
|
||||
43 -> EmojiRepresentation("✏️", R.string.verification_emoji_pencil, R.drawable.ic_verification_pencil)
|
||||
44 -> EmojiRepresentation("📎", R.string.verification_emoji_paperclip, R.drawable.ic_verification_paperclip)
|
||||
45 -> EmojiRepresentation("✂️", R.string.verification_emoji_scissors, R.drawable.ic_verification_scissors)
|
||||
46 -> EmojiRepresentation("🔒", R.string.verification_emoji_lock, R.drawable.ic_verification_lock)
|
||||
47 -> EmojiRepresentation("🔑", R.string.verification_emoji_key, R.drawable.ic_verification_key)
|
||||
48 -> EmojiRepresentation("🔨", R.string.verification_emoji_hammer, R.drawable.ic_verification_hammer)
|
||||
49 -> EmojiRepresentation("☎️", R.string.verification_emoji_telephone, R.drawable.ic_verification_phone)
|
||||
50 -> EmojiRepresentation("🏁", R.string.verification_emoji_flag, R.drawable.ic_verification_flag)
|
||||
51 -> EmojiRepresentation("🚂", R.string.verification_emoji_train, R.drawable.ic_verification_train)
|
||||
52 -> EmojiRepresentation("🚲", R.string.verification_emoji_bicycle, R.drawable.ic_verification_bicycle)
|
||||
53 -> EmojiRepresentation("✈️", R.string.verification_emoji_aeroplane, R.drawable.ic_verification_aeroplane)
|
||||
54 -> EmojiRepresentation("🚀", R.string.verification_emoji_rocket, R.drawable.ic_verification_rocket)
|
||||
55 -> EmojiRepresentation("🏆", R.string.verification_emoji_trophy, R.drawable.ic_verification_trophy)
|
||||
56 -> EmojiRepresentation("⚽", R.string.verification_emoji_ball, R.drawable.ic_verification_ball)
|
||||
57 -> EmojiRepresentation("🎸", R.string.verification_emoji_guitar, R.drawable.ic_verification_guitar)
|
||||
58 -> EmojiRepresentation("🎺", R.string.verification_emoji_trumpet, R.drawable.ic_verification_trumpet)
|
||||
59 -> EmojiRepresentation("🔔", R.string.verification_emoji_bell, R.drawable.ic_verification_bell)
|
||||
60 -> EmojiRepresentation("⚓", R.string.verification_emoji_anchor, R.drawable.ic_verification_anchor)
|
||||
61 -> EmojiRepresentation("🎧", R.string.verification_emoji_headphones, R.drawable.ic_verification_headphones)
|
||||
62 -> EmojiRepresentation("📁", R.string.verification_emoji_folder, R.drawable.ic_verification_folder)
|
||||
0 -> EmojiRepresentation("🐶", R.string.verification_emoji_dog, R.drawable.ic_verification_dog)
|
||||
1 -> EmojiRepresentation("🐱", R.string.verification_emoji_cat, R.drawable.ic_verification_cat)
|
||||
2 -> EmojiRepresentation("🦁", R.string.verification_emoji_lion, R.drawable.ic_verification_lion)
|
||||
3 -> EmojiRepresentation("🐎", R.string.verification_emoji_horse, R.drawable.ic_verification_horse)
|
||||
4 -> EmojiRepresentation("🦄", R.string.verification_emoji_unicorn, R.drawable.ic_verification_unicorn)
|
||||
5 -> EmojiRepresentation("🐷", R.string.verification_emoji_pig, R.drawable.ic_verification_pig)
|
||||
6 -> EmojiRepresentation("🐘", R.string.verification_emoji_elephant, R.drawable.ic_verification_elephant)
|
||||
7 -> EmojiRepresentation("🐰", R.string.verification_emoji_rabbit, R.drawable.ic_verification_rabbit)
|
||||
8 -> EmojiRepresentation("🐼", R.string.verification_emoji_panda, R.drawable.ic_verification_panda)
|
||||
9 -> EmojiRepresentation("🐓", R.string.verification_emoji_rooster, R.drawable.ic_verification_rooster)
|
||||
10 -> EmojiRepresentation("🐧", R.string.verification_emoji_penguin, R.drawable.ic_verification_penguin)
|
||||
11 -> EmojiRepresentation("🐢", R.string.verification_emoji_turtle, R.drawable.ic_verification_turtle)
|
||||
12 -> EmojiRepresentation("🐟", R.string.verification_emoji_fish, R.drawable.ic_verification_fish)
|
||||
13 -> EmojiRepresentation("🐙", R.string.verification_emoji_octopus, R.drawable.ic_verification_octopus)
|
||||
14 -> EmojiRepresentation("🦋", R.string.verification_emoji_butterfly, R.drawable.ic_verification_butterfly)
|
||||
15 -> EmojiRepresentation("🌷", R.string.verification_emoji_flower, R.drawable.ic_verification_flower)
|
||||
16 -> EmojiRepresentation("🌳", R.string.verification_emoji_tree, R.drawable.ic_verification_tree)
|
||||
17 -> EmojiRepresentation("🌵", R.string.verification_emoji_cactus, R.drawable.ic_verification_cactus)
|
||||
18 -> EmojiRepresentation("🍄", R.string.verification_emoji_mushroom, R.drawable.ic_verification_mushroom)
|
||||
19 -> EmojiRepresentation("🌏", R.string.verification_emoji_globe, R.drawable.ic_verification_globe)
|
||||
20 -> EmojiRepresentation("🌙", R.string.verification_emoji_moon, R.drawable.ic_verification_moon)
|
||||
21 -> EmojiRepresentation("☁️", R.string.verification_emoji_cloud, R.drawable.ic_verification_cloud)
|
||||
22 -> EmojiRepresentation("🔥", R.string.verification_emoji_fire, R.drawable.ic_verification_fire)
|
||||
23 -> EmojiRepresentation("🍌", R.string.verification_emoji_banana, R.drawable.ic_verification_banana)
|
||||
24 -> EmojiRepresentation("🍎", R.string.verification_emoji_apple, R.drawable.ic_verification_apple)
|
||||
25 -> EmojiRepresentation("🍓", R.string.verification_emoji_strawberry, R.drawable.ic_verification_strawberry)
|
||||
26 -> EmojiRepresentation("🌽", R.string.verification_emoji_corn, R.drawable.ic_verification_corn)
|
||||
27 -> EmojiRepresentation("🍕", R.string.verification_emoji_pizza, R.drawable.ic_verification_pizza)
|
||||
28 -> EmojiRepresentation("🎂", R.string.verification_emoji_cake, R.drawable.ic_verification_cake)
|
||||
29 -> EmojiRepresentation("❤️", R.string.verification_emoji_heart, R.drawable.ic_verification_heart)
|
||||
30 -> EmojiRepresentation("🙂", R.string.verification_emoji_smiley, R.drawable.ic_verification_smiley)
|
||||
31 -> EmojiRepresentation("🤖", R.string.verification_emoji_robot, R.drawable.ic_verification_robot)
|
||||
32 -> EmojiRepresentation("🎩", R.string.verification_emoji_hat, R.drawable.ic_verification_hat)
|
||||
33 -> EmojiRepresentation("👓", R.string.verification_emoji_glasses, R.drawable.ic_verification_glasses)
|
||||
34 -> EmojiRepresentation("🔧", R.string.verification_emoji_spanner, R.drawable.ic_verification_spanner)
|
||||
35 -> EmojiRepresentation("🎅", R.string.verification_emoji_santa, R.drawable.ic_verification_santa)
|
||||
36 -> EmojiRepresentation("👍", R.string.verification_emoji_thumbs_up, R.drawable.ic_verification_thumbs_up)
|
||||
37 -> EmojiRepresentation("☂️", R.string.verification_emoji_umbrella, R.drawable.ic_verification_umbrella)
|
||||
38 -> EmojiRepresentation("⌛", R.string.verification_emoji_hourglass, R.drawable.ic_verification_hourglass)
|
||||
39 -> EmojiRepresentation("⏰", R.string.verification_emoji_clock, R.drawable.ic_verification_clock)
|
||||
40 -> EmojiRepresentation("🎁", R.string.verification_emoji_gift, R.drawable.ic_verification_gift)
|
||||
41 -> EmojiRepresentation("💡", R.string.verification_emoji_light_bulb, R.drawable.ic_verification_light_bulb)
|
||||
42 -> EmojiRepresentation("📕", R.string.verification_emoji_book, R.drawable.ic_verification_book)
|
||||
43 -> EmojiRepresentation("✏️", R.string.verification_emoji_pencil, R.drawable.ic_verification_pencil)
|
||||
44 -> EmojiRepresentation("📎", R.string.verification_emoji_paperclip, R.drawable.ic_verification_paperclip)
|
||||
45 -> EmojiRepresentation("✂️", R.string.verification_emoji_scissors, R.drawable.ic_verification_scissors)
|
||||
46 -> EmojiRepresentation("🔒", R.string.verification_emoji_lock, R.drawable.ic_verification_lock)
|
||||
47 -> EmojiRepresentation("🔑", R.string.verification_emoji_key, R.drawable.ic_verification_key)
|
||||
48 -> EmojiRepresentation("🔨", R.string.verification_emoji_hammer, R.drawable.ic_verification_hammer)
|
||||
49 -> EmojiRepresentation("☎️", R.string.verification_emoji_telephone, R.drawable.ic_verification_phone)
|
||||
50 -> EmojiRepresentation("🏁", R.string.verification_emoji_flag, R.drawable.ic_verification_flag)
|
||||
51 -> EmojiRepresentation("🚂", R.string.verification_emoji_train, R.drawable.ic_verification_train)
|
||||
52 -> EmojiRepresentation("🚲", R.string.verification_emoji_bicycle, R.drawable.ic_verification_bicycle)
|
||||
53 -> EmojiRepresentation("✈️", R.string.verification_emoji_aeroplane, R.drawable.ic_verification_aeroplane)
|
||||
54 -> EmojiRepresentation("🚀", R.string.verification_emoji_rocket, R.drawable.ic_verification_rocket)
|
||||
55 -> EmojiRepresentation("🏆", R.string.verification_emoji_trophy, R.drawable.ic_verification_trophy)
|
||||
56 -> EmojiRepresentation("⚽", R.string.verification_emoji_ball, R.drawable.ic_verification_ball)
|
||||
57 -> EmojiRepresentation("🎸", R.string.verification_emoji_guitar, R.drawable.ic_verification_guitar)
|
||||
58 -> EmojiRepresentation("🎺", R.string.verification_emoji_trumpet, R.drawable.ic_verification_trumpet)
|
||||
59 -> EmojiRepresentation("🔔", R.string.verification_emoji_bell, R.drawable.ic_verification_bell)
|
||||
60 -> EmojiRepresentation("⚓", R.string.verification_emoji_anchor, R.drawable.ic_verification_anchor)
|
||||
61 -> EmojiRepresentation("🎧", R.string.verification_emoji_headphones, R.drawable.ic_verification_headphones)
|
||||
62 -> EmojiRepresentation("📁", R.string.verification_emoji_folder, R.drawable.ic_verification_folder)
|
||||
/* 63 */ else -> EmojiRepresentation("📌", R.string.verification_emoji_pin, R.drawable.ic_verification_pin)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ internal interface VerificationInfoStart : VerificationInfo<ValidVerificationInf
|
|||
val validFromDevice = fromDevice?.takeIf { it.isNotEmpty() } ?: return null
|
||||
|
||||
return when (method) {
|
||||
VERIFICATION_METHOD_SAS -> {
|
||||
VERIFICATION_METHOD_SAS -> {
|
||||
val validKeyAgreementProtocols = keyAgreementProtocols?.takeIf { it.isNotEmpty() } ?: return null
|
||||
val validHashes = hashes?.takeIf { it.contains("sha256") } ?: return null
|
||||
val validMessageAuthenticationCodes = messageAuthenticationCodes
|
||||
|
@ -98,7 +98,7 @@ internal interface VerificationInfoStart : VerificationInfo<ValidVerificationInf
|
|||
validSharedSecret
|
||||
)
|
||||
}
|
||||
else -> null
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ internal class VerificationMessageProcessor @Inject constructor(
|
|||
EventType.KEY_VERIFICATION_DONE -> {
|
||||
verificationService.onRoomEvent(event)
|
||||
}
|
||||
EventType.MESSAGE -> {
|
||||
EventType.MESSAGE -> {
|
||||
if (MessageType.MSGTYPE_VERIFICATION_REQUEST == event.getClearContent().toModel<MessageContent>()?.msgType) {
|
||||
verificationService.onRoomRequestReceived(event)
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ internal class DefaultQrCodeVerificationTransaction(
|
|||
|
||||
// Check the other device view of my MSK
|
||||
when (otherQrCodeData) {
|
||||
is QrCodeData.VerifyingAnotherUser -> {
|
||||
is QrCodeData.VerifyingAnotherUser -> {
|
||||
// key2 (aka otherUserMasterCrossSigningPublicKey) is what the one displaying the QR code (other user) think my MSK is.
|
||||
// Let's check that it's correct
|
||||
// If not -> Cancel
|
||||
|
@ -104,7 +104,7 @@ internal class DefaultQrCodeVerificationTransaction(
|
|||
return
|
||||
} else Unit
|
||||
}
|
||||
is QrCodeData.SelfVerifyingMasterKeyTrusted -> {
|
||||
is QrCodeData.SelfVerifyingMasterKeyTrusted -> {
|
||||
// key1 (aka userMasterCrossSigningPublicKey) is the session displaying the QR code view of our MSK.
|
||||
// Let's check that I see the same MSK
|
||||
// If not -> Cancel
|
||||
|
@ -135,7 +135,7 @@ internal class DefaultQrCodeVerificationTransaction(
|
|||
|
||||
// Let's now check the other user/device key material
|
||||
when (otherQrCodeData) {
|
||||
is QrCodeData.VerifyingAnotherUser -> {
|
||||
is QrCodeData.VerifyingAnotherUser -> {
|
||||
// key1(aka userMasterCrossSigningPublicKey) is the MSK of the one displaying the QR code (i.e other user)
|
||||
// Let's check that it matches what I think it should be
|
||||
if (otherQrCodeData.userMasterCrossSigningPublicKey
|
||||
|
@ -149,7 +149,7 @@ internal class DefaultQrCodeVerificationTransaction(
|
|||
Unit
|
||||
}
|
||||
}
|
||||
is QrCodeData.SelfVerifyingMasterKeyTrusted -> {
|
||||
is QrCodeData.SelfVerifyingMasterKeyTrusted -> {
|
||||
// key2 (aka otherDeviceKey) is my current device key in POV of the one displaying the QR code (i.e other device)
|
||||
// Let's check that it's correct
|
||||
if (otherQrCodeData.otherDeviceKey
|
||||
|
@ -259,11 +259,11 @@ internal class DefaultQrCodeVerificationTransaction(
|
|||
|
||||
override fun otherUserScannedMyQrCode() {
|
||||
when (qrCodeData) {
|
||||
is QrCodeData.VerifyingAnotherUser -> {
|
||||
is QrCodeData.VerifyingAnotherUser -> {
|
||||
// Alice telling Bob that the code was scanned successfully is sufficient for Bob to trust Alice's key,
|
||||
trust(true, emptyList(), false)
|
||||
}
|
||||
is QrCodeData.SelfVerifyingMasterKeyTrusted -> {
|
||||
is QrCodeData.SelfVerifyingMasterKeyTrusted -> {
|
||||
// I now know that I have the correct device key for other session,
|
||||
// and can sign it with the self-signing key and upload the signature
|
||||
trust(false, listOf(otherDeviceId ?: ""), false)
|
||||
|
@ -272,7 +272,7 @@ internal class DefaultQrCodeVerificationTransaction(
|
|||
// I now know that i can trust my MSK
|
||||
trust(true, emptyList(), true)
|
||||
}
|
||||
null -> Unit
|
||||
null -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ internal fun QrCodeData.toEncodedString(): String {
|
|||
|
||||
// Mode
|
||||
result += when (this) {
|
||||
is QrCodeData.VerifyingAnotherUser -> 0
|
||||
is QrCodeData.SelfVerifyingMasterKeyTrusted -> 1
|
||||
is QrCodeData.VerifyingAnotherUser -> 0
|
||||
is QrCodeData.SelfVerifyingMasterKeyTrusted -> 1
|
||||
is QrCodeData.SelfVerifyingMasterKeyNotTrusted -> 2
|
||||
}.toByte()
|
||||
|
||||
|
@ -119,9 +119,9 @@ internal fun String.toQrCodeData(): QrCodeData? {
|
|||
val secret = byteArray.copyOfRange(cursor, byteArray.size).toBase64NoPadding()
|
||||
|
||||
return when (mode) {
|
||||
0 -> QrCodeData.VerifyingAnotherUser(transactionId, key1, key2, secret)
|
||||
1 -> QrCodeData.SelfVerifyingMasterKeyTrusted(transactionId, key1, key2, secret)
|
||||
2 -> QrCodeData.SelfVerifyingMasterKeyNotTrusted(transactionId, key1, key2, secret)
|
||||
0 -> QrCodeData.VerifyingAnotherUser(transactionId, key1, key2, secret)
|
||||
1 -> QrCodeData.SelfVerifyingMasterKeyTrusted(transactionId, key1, key2, secret)
|
||||
2 -> QrCodeData.SelfVerifyingMasterKeyNotTrusted(transactionId, key1, key2, secret)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ private fun handleReadReceipts(realm: Realm, roomId: String, eventEntity: EventE
|
|||
|
||||
internal fun ChunkEntity.nextDisplayIndex(direction: PaginationDirection): Int {
|
||||
return when (direction) {
|
||||
PaginationDirection.FORWARDS -> {
|
||||
PaginationDirection.FORWARDS -> {
|
||||
(timelineEvents.where().max(TimelineEventEntityFields.DISPLAY_INDEX)?.toInt() ?: 0) + 1
|
||||
}
|
||||
PaginationDirection.BACKWARDS -> {
|
||||
|
|
|
@ -181,7 +181,7 @@ internal fun ThreadSummaryEntity.Companion.createOrUpdate(
|
|||
|
||||
roomEntity.addIfNecessary(threadSummary)
|
||||
}
|
||||
ThreadSummaryUpdateType.ADD -> {
|
||||
ThreadSummaryUpdateType.ADD -> {
|
||||
val rootThreadEventId = threadEventEntity?.rootThreadEventId ?: return
|
||||
Timber.i("###THREADS ThreadSummaryHelper ADD for root eventId:$rootThreadEventId")
|
||||
|
||||
|
|
|
@ -27,21 +27,21 @@ internal object DraftMapper {
|
|||
fun map(entity: DraftEntity): UserDraft {
|
||||
return when (entity.draftMode) {
|
||||
DraftEntity.MODE_REGULAR -> UserDraft.Regular(entity.content)
|
||||
DraftEntity.MODE_EDIT -> UserDraft.Edit(entity.linkedEventId, entity.content)
|
||||
DraftEntity.MODE_QUOTE -> UserDraft.Quote(entity.linkedEventId, entity.content)
|
||||
DraftEntity.MODE_REPLY -> UserDraft.Reply(entity.linkedEventId, entity.content)
|
||||
DraftEntity.MODE_VOICE -> UserDraft.Voice(entity.content)
|
||||
else -> null
|
||||
DraftEntity.MODE_EDIT -> UserDraft.Edit(entity.linkedEventId, entity.content)
|
||||
DraftEntity.MODE_QUOTE -> UserDraft.Quote(entity.linkedEventId, entity.content)
|
||||
DraftEntity.MODE_REPLY -> UserDraft.Reply(entity.linkedEventId, entity.content)
|
||||
DraftEntity.MODE_VOICE -> UserDraft.Voice(entity.content)
|
||||
else -> null
|
||||
} ?: UserDraft.Regular("")
|
||||
}
|
||||
|
||||
fun map(domain: UserDraft): DraftEntity {
|
||||
return when (domain) {
|
||||
is UserDraft.Regular -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_REGULAR, linkedEventId = "")
|
||||
is UserDraft.Edit -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_EDIT, linkedEventId = domain.linkedEventId)
|
||||
is UserDraft.Quote -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_QUOTE, linkedEventId = domain.linkedEventId)
|
||||
is UserDraft.Reply -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_REPLY, linkedEventId = domain.linkedEventId)
|
||||
is UserDraft.Voice -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_VOICE, linkedEventId = "")
|
||||
is UserDraft.Edit -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_EDIT, linkedEventId = domain.linkedEventId)
|
||||
is UserDraft.Quote -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_QUOTE, linkedEventId = domain.linkedEventId)
|
||||
is UserDraft.Reply -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_REPLY, linkedEventId = domain.linkedEventId)
|
||||
is UserDraft.Voice -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_VOICE, linkedEventId = "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ internal object IsUselessResolver {
|
|||
event.content != null &&
|
||||
event.content.toContent() == event.resolvedPrevContent()?.toContent()
|
||||
}
|
||||
else -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ internal class RoomSummaryMapper @Inject constructor(
|
|||
// I should probably use #hasEncryptorClassForAlgorithm but it says it supports
|
||||
// OLM which is some legacy? Now only megolm allowed in rooms
|
||||
MXCRYPTO_ALGORITHM_MEGOLM -> RoomEncryptionAlgorithm.Megolm
|
||||
else -> RoomEncryptionAlgorithm.UnsupportedAlgorithm(alg)
|
||||
else -> RoomEncryptionAlgorithm.UnsupportedAlgorithm(alg)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -41,12 +41,12 @@ internal fun isEventRead(
|
|||
val eventToCheck = TimelineEventEntity.where(realm, roomId, eventId).findFirst()
|
||||
when {
|
||||
// The event doesn't exist locally, let's assume it hasn't been read
|
||||
eventToCheck == null -> false
|
||||
eventToCheck.root?.sender == userId -> true
|
||||
eventToCheck == null -> false
|
||||
eventToCheck.root?.sender == userId -> true
|
||||
// If new event exists and the latest event is from ourselves we can infer the event is read
|
||||
latestEventIsFromSelf(realm, roomId, userId) -> true
|
||||
latestEventIsFromSelf(realm, roomId, userId) -> true
|
||||
eventToCheck.isBeforeLatestReadReceipt(realm, roomId, userId) -> true
|
||||
else -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,8 +56,8 @@ internal suspend inline fun <DATA> executeRequest(
|
|||
} catch (throwable: Throwable) {
|
||||
val exception = when (throwable) {
|
||||
is KotlinNullPointerException -> IllegalStateException("The request returned a null body")
|
||||
is HttpException -> throwable.toFailure(globalErrorReceiver)
|
||||
else -> throwable
|
||||
is HttpException -> throwable.toFailure(globalErrorReceiver)
|
||||
else -> throwable
|
||||
}
|
||||
|
||||
// Log some details about the request which has failed.
|
||||
|
@ -94,11 +94,11 @@ internal suspend inline fun <DATA> executeRequest(
|
|||
// Try again (loop)
|
||||
} else {
|
||||
throw when (exception) {
|
||||
is IOException -> Failure.NetworkConnection(exception)
|
||||
is IOException -> Failure.NetworkConnection(exception)
|
||||
is Failure.ServerError,
|
||||
is Failure.OtherServerError,
|
||||
is CancellationException -> exception
|
||||
else -> Failure.Unknown(exception)
|
||||
else -> Failure.Unknown(exception)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,10 +92,10 @@ private fun toFailure(errorBody: ResponseBody?, httpCode: Int, globalErrorReceiv
|
|||
globalErrorReceiver?.handleGlobalError(GlobalError.ConsentNotGivenError(matrixError.consentUri))
|
||||
}
|
||||
httpCode == HttpURLConnection.HTTP_UNAUTHORIZED && /* 401 */
|
||||
matrixError.code == MatrixError.M_UNKNOWN_TOKEN -> {
|
||||
matrixError.code == MatrixError.M_UNKNOWN_TOKEN -> {
|
||||
globalErrorReceiver?.handleGlobalError(GlobalError.InvalidToken(matrixError.isSoftLogout.orFalse()))
|
||||
}
|
||||
matrixError.code == MatrixError.ORG_MATRIX_EXPIRED_ACCOUNT -> {
|
||||
matrixError.code == MatrixError.ORG_MATRIX_EXPIRED_ACCOUNT -> {
|
||||
globalErrorReceiver?.handleGlobalError(GlobalError.ExpiredAccount)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,9 +37,9 @@ internal class ForceToBooleanJsonAdapter {
|
|||
@ForceToBoolean
|
||||
fun fromJson(reader: JsonReader): Boolean {
|
||||
return when (val token = reader.peek()) {
|
||||
JsonReader.Token.NUMBER -> reader.nextInt() != 0
|
||||
JsonReader.Token.NUMBER -> reader.nextInt() != 0
|
||||
JsonReader.Token.BOOLEAN -> reader.nextBoolean()
|
||||
else -> {
|
||||
else -> {
|
||||
Timber.e("Expecting a boolean or a int but get: $token")
|
||||
reader.skipValue()
|
||||
false
|
||||
|
|
|
@ -24,10 +24,10 @@ import org.matrix.android.sdk.internal.database.model.RoomSummaryEntityFields
|
|||
|
||||
internal fun RealmQuery<RoomSummaryEntity>.process(sortOrder: RoomSortOrder): RealmQuery<RoomSummaryEntity> {
|
||||
when (sortOrder) {
|
||||
RoomSortOrder.NAME -> {
|
||||
RoomSortOrder.NAME -> {
|
||||
sort(RoomSummaryEntityFields.DISPLAY_NAME, Sort.ASCENDING)
|
||||
}
|
||||
RoomSortOrder.ACTIVITY -> {
|
||||
RoomSortOrder.ACTIVITY -> {
|
||||
sort(RoomSummaryEntityFields.LAST_ACTIVITY_TIME, Sort.DESCENDING)
|
||||
}
|
||||
RoomSortOrder.PRIORITY_AND_ACTIVITY -> {
|
||||
|
@ -40,7 +40,7 @@ internal fun RealmQuery<RoomSummaryEntity>.process(sortOrder: RoomSortOrder): Re
|
|||
arrayOf(Sort.DESCENDING, Sort.ASCENDING, Sort.DESCENDING)
|
||||
)
|
||||
}
|
||||
RoomSortOrder.NONE -> {
|
||||
RoomSortOrder.NONE -> {
|
||||
}
|
||||
}
|
||||
return this
|
||||
|
|
|
@ -31,12 +31,12 @@ internal class QueryStringValueProcessor @Inject constructor(
|
|||
fun <T : RealmObject> RealmQuery<T>.process(field: String, queryStringValue: QueryStringValue): RealmQuery<T> {
|
||||
return when (queryStringValue) {
|
||||
is QueryStringValue.NoCondition -> this
|
||||
is QueryStringValue.IsNotNull -> isNotNull(field)
|
||||
is QueryStringValue.IsNull -> isNull(field)
|
||||
is QueryStringValue.IsEmpty -> isEmpty(field)
|
||||
is QueryStringValue.IsNotEmpty -> isNotEmpty(field)
|
||||
is ContentQueryStringValue -> when (queryStringValue) {
|
||||
is QueryStringValue.Equals -> equalTo(field, queryStringValue.toRealmValue(), queryStringValue.case.toRealmCase())
|
||||
is QueryStringValue.IsNotNull -> isNotNull(field)
|
||||
is QueryStringValue.IsNull -> isNull(field)
|
||||
is QueryStringValue.IsEmpty -> isEmpty(field)
|
||||
is QueryStringValue.IsNotEmpty -> isNotEmpty(field)
|
||||
is ContentQueryStringValue -> when (queryStringValue) {
|
||||
is QueryStringValue.Equals -> equalTo(field, queryStringValue.toRealmValue(), queryStringValue.case.toRealmCase())
|
||||
is QueryStringValue.Contains -> contains(field, queryStringValue.toRealmValue(), queryStringValue.case.toRealmCase())
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ internal class QueryStringValueProcessor @Inject constructor(
|
|||
|
||||
private fun ContentQueryStringValue.toRealmValue(): String {
|
||||
return when (case) {
|
||||
QueryStringValue.Case.NORMALIZED -> normalizer.normalize(string)
|
||||
QueryStringValue.Case.NORMALIZED -> normalizer.normalize(string)
|
||||
QueryStringValue.Case.SENSITIVE,
|
||||
QueryStringValue.Case.INSENSITIVE -> string
|
||||
}
|
||||
|
@ -55,6 +55,6 @@ private fun QueryStringValue.Case.toRealmCase(): Case {
|
|||
return when (this) {
|
||||
QueryStringValue.Case.INSENSITIVE -> Case.INSENSITIVE
|
||||
QueryStringValue.Case.SENSITIVE,
|
||||
QueryStringValue.Case.NORMALIZED -> Case.SENSITIVE
|
||||
QueryStringValue.Case.NORMALIZED -> Case.SENSITIVE
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ internal class DefaultGetUrlTask @Inject constructor(
|
|||
|
||||
override suspend fun execute(params: GetUrlTask.Params): String {
|
||||
return when (params.cacheStrategy) {
|
||||
CacheStrategy.NoCache -> doRequest(params.url)
|
||||
is CacheStrategy.TtlCache -> doRequestWithCache(
|
||||
CacheStrategy.NoCache -> doRequest(params.url)
|
||||
is CacheStrategy.TtlCache -> doRequestWithCache(
|
||||
params.url,
|
||||
params.cacheStrategy.validityDurationInMillis,
|
||||
params.cacheStrategy.strict
|
||||
|
|
|
@ -127,7 +127,7 @@ internal class DefaultFileService @Inject constructor(
|
|||
val resolvedUrl = contentUrlResolver.resolveForDownload(url, elementToDecrypt) ?: throw IllegalArgumentException("url is null")
|
||||
|
||||
val request = when (resolvedUrl) {
|
||||
is ContentUrlResolver.ResolvedMethod.GET -> {
|
||||
is ContentUrlResolver.ResolvedMethod.GET -> {
|
||||
Request.Builder()
|
||||
.url(resolvedUrl.url)
|
||||
.header(DOWNLOAD_PROGRESS_INTERCEPTOR_HEADER, url)
|
||||
|
|
|
@ -63,25 +63,25 @@ internal class CallSignalingHandler @Inject constructor(
|
|||
|
||||
fun onCallEvent(event: Event) {
|
||||
when (event.getClearType()) {
|
||||
EventType.CALL_ANSWER -> {
|
||||
EventType.CALL_ANSWER -> {
|
||||
handleCallAnswerEvent(event)
|
||||
}
|
||||
EventType.CALL_INVITE -> {
|
||||
EventType.CALL_INVITE -> {
|
||||
handleCallInviteEvent(event)
|
||||
}
|
||||
EventType.CALL_HANGUP -> {
|
||||
EventType.CALL_HANGUP -> {
|
||||
handleCallHangupEvent(event)
|
||||
}
|
||||
EventType.CALL_REJECT -> {
|
||||
EventType.CALL_REJECT -> {
|
||||
handleCallRejectEvent(event)
|
||||
}
|
||||
EventType.CALL_CANDIDATES -> {
|
||||
EventType.CALL_CANDIDATES -> {
|
||||
handleCallCandidatesEvent(event)
|
||||
}
|
||||
EventType.CALL_SELECT_ANSWER -> {
|
||||
EventType.CALL_SELECT_ANSWER -> {
|
||||
handleCallSelectAnswerEvent(event)
|
||||
}
|
||||
EventType.CALL_NEGOTIATE -> {
|
||||
EventType.CALL_NEGOTIATE -> {
|
||||
handleCallNegotiateEvent(event)
|
||||
}
|
||||
EventType.CALL_ASSERTED_IDENTITY,
|
||||
|
|
|
@ -69,20 +69,20 @@ internal class ImageCompressor @Inject constructor(
|
|||
val orientation = exifInfo.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL)
|
||||
val matrix = Matrix()
|
||||
when (orientation) {
|
||||
ExifInterface.ORIENTATION_ROTATE_270 -> matrix.postRotate(270f)
|
||||
ExifInterface.ORIENTATION_ROTATE_180 -> matrix.postRotate(180f)
|
||||
ExifInterface.ORIENTATION_ROTATE_90 -> matrix.postRotate(90f)
|
||||
ExifInterface.ORIENTATION_ROTATE_270 -> matrix.postRotate(270f)
|
||||
ExifInterface.ORIENTATION_ROTATE_180 -> matrix.postRotate(180f)
|
||||
ExifInterface.ORIENTATION_ROTATE_90 -> matrix.postRotate(90f)
|
||||
ExifInterface.ORIENTATION_FLIP_HORIZONTAL -> matrix.preScale(-1f, 1f)
|
||||
ExifInterface.ORIENTATION_FLIP_VERTICAL -> matrix.preScale(1f, -1f)
|
||||
ExifInterface.ORIENTATION_TRANSPOSE -> {
|
||||
ExifInterface.ORIENTATION_FLIP_VERTICAL -> matrix.preScale(1f, -1f)
|
||||
ExifInterface.ORIENTATION_TRANSPOSE -> {
|
||||
matrix.preRotate(-90f)
|
||||
matrix.preScale(-1f, 1f)
|
||||
}
|
||||
ExifInterface.ORIENTATION_TRANSVERSE -> {
|
||||
ExifInterface.ORIENTATION_TRANSVERSE -> {
|
||||
matrix.preRotate(90f)
|
||||
matrix.preScale(-1f, 1f)
|
||||
}
|
||||
else -> return bitmap
|
||||
else -> return bitmap
|
||||
}
|
||||
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, true)
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
|
|||
})
|
||||
.let { videoCompressionResult ->
|
||||
when (videoCompressionResult) {
|
||||
is VideoCompressionResult.Success -> {
|
||||
is VideoCompressionResult.Success -> {
|
||||
val compressedFile = videoCompressionResult.compressedFile
|
||||
var compressedWidth: Int? = null
|
||||
var compressedHeight: Int? = null
|
||||
|
@ -411,9 +411,9 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
|
|||
val updatedContent = when (messageContent) {
|
||||
is MessageImageContent -> messageContent.update(url, encryptedFileInfo, newAttachmentAttributes)
|
||||
is MessageVideoContent -> messageContent.update(url, encryptedFileInfo, thumbnailUrl, thumbnailEncryptedFileInfo, newAttachmentAttributes)
|
||||
is MessageFileContent -> messageContent.update(url, encryptedFileInfo, newAttachmentAttributes.newFileSize)
|
||||
is MessageFileContent -> messageContent.update(url, encryptedFileInfo, newAttachmentAttributes.newFileSize)
|
||||
is MessageAudioContent -> messageContent.update(url, encryptedFileInfo, newAttachmentAttributes.newFileSize)
|
||||
else -> messageContent
|
||||
else -> messageContent
|
||||
}
|
||||
event.content = ContentMapper.map(updatedContent.toContent())
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ internal class VideoCompressor @Inject constructor(
|
|||
deleteFile(destinationFile)
|
||||
VideoCompressionResult.CompressionNotNeeded
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
// Should not happen...
|
||||
// Delete now the temporary file
|
||||
deleteFile(destinationFile)
|
||||
|
|
|
@ -106,7 +106,7 @@ internal class RealmContentScannerStore @Inject constructor(
|
|||
ScanState.IN_PROGRESS,
|
||||
ScanState.TRUSTED,
|
||||
ScanState.INFECTED -> true
|
||||
else -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
return isKnown
|
||||
|
|
|
@ -45,7 +45,7 @@ internal class DefaultSaveFilterTask @Inject constructor(
|
|||
FilterService.FilterPreset.ElementFilter -> {
|
||||
FilterFactory.createElementFilter()
|
||||
}
|
||||
FilterService.FilterPreset.NoFilter -> {
|
||||
FilterService.FilterPreset.NoFilter -> {
|
||||
FilterFactory.createDefaultFilter()
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ internal class DefaultSaveFilterTask @Inject constructor(
|
|||
FilterService.FilterPreset.ElementFilter -> {
|
||||
FilterFactory.createElementRoomFilter()
|
||||
}
|
||||
FilterService.FilterPreset.NoFilter -> {
|
||||
FilterService.FilterPreset.NoFilter -> {
|
||||
FilterFactory.createDefaultRoomFilter()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ internal class DefaultGetGroupDataTask @Inject constructor(
|
|||
is GetGroupDataTask.Params.FetchAllActive -> {
|
||||
getActiveGroupIds()
|
||||
}
|
||||
is GetGroupDataTask.Params.FetchWithIds -> {
|
||||
is GetGroupDataTask.Params.FetchWithIds -> {
|
||||
params.groupIds
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,8 +283,8 @@ internal class DefaultIdentityService @Inject constructor(
|
|||
identityStore.setToken(null)
|
||||
lookUpInternal(false, threePids)
|
||||
}
|
||||
throwable.isTermsNotSigned() -> throw IdentityServiceError.TermsNotSignedException
|
||||
else -> throw throwable
|
||||
throwable.isTermsNotSigned() -> throw IdentityServiceError.TermsNotSignedException
|
||||
else -> throw throwable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ internal class DefaultIdentityRequestTokenForBindingTask @Inject constructor(
|
|||
|
||||
val tokenResponse = executeRequest(null) {
|
||||
when (params.threePid) {
|
||||
is ThreePid.Email -> identityAPI.requestTokenToBindEmail(
|
||||
is ThreePid.Email -> identityAPI.requestTokenToBindEmail(
|
||||
IdentityRequestTokenForEmailBody(
|
||||
clientSecret = clientSecret,
|
||||
sendAttempt = sendAttempt,
|
||||
|
|
|
@ -48,8 +48,8 @@ internal class DefaultGetPreviewUrlTask @Inject constructor(
|
|||
|
||||
override suspend fun execute(params: GetPreviewUrlTask.Params): PreviewUrlData {
|
||||
return when (params.cacheStrategy) {
|
||||
CacheStrategy.NoCache -> doRequest(params.url, params.timestamp)
|
||||
is CacheStrategy.TtlCache -> doRequestWithCache(
|
||||
CacheStrategy.NoCache -> doRequest(params.url, params.timestamp)
|
||||
is CacheStrategy.TtlCache -> doRequestWithCache(
|
||||
params.url,
|
||||
params.timestamp,
|
||||
params.cacheStrategy.validityDurationInMillis,
|
||||
|
|
|
@ -44,15 +44,15 @@ internal class PermalinkFactory @Inject constructor(
|
|||
|
||||
fun createPermalink(id: String, forceMatrixTo: Boolean): String? {
|
||||
return when {
|
||||
id.isEmpty() -> null
|
||||
id.isEmpty() -> null
|
||||
!useClientFormat(forceMatrixTo) -> MATRIX_TO_URL_BASE + escape(id)
|
||||
else -> {
|
||||
else -> {
|
||||
buildString {
|
||||
append(matrixConfiguration.clientPermalinkBaseUrl)
|
||||
when {
|
||||
MatrixPatterns.isRoomId(id) || MatrixPatterns.isRoomAlias(id) -> append(ROOM_PATH)
|
||||
MatrixPatterns.isUserId(id) -> append(USER_PATH)
|
||||
MatrixPatterns.isGroupId(id) -> append(GROUP_PATH)
|
||||
MatrixPatterns.isUserId(id) -> append(USER_PATH)
|
||||
MatrixPatterns.isGroupId(id) -> append(GROUP_PATH)
|
||||
}
|
||||
append(escape(id))
|
||||
}
|
||||
|
@ -94,16 +94,16 @@ internal class PermalinkFactory @Inject constructor(
|
|||
fun getLinkedId(url: String): String? {
|
||||
val clientBaseUrl = matrixConfiguration.clientPermalinkBaseUrl
|
||||
return when {
|
||||
url.startsWith(MATRIX_TO_URL_BASE) -> url.substring(MATRIX_TO_URL_BASE.length)
|
||||
url.startsWith(MATRIX_TO_URL_BASE) -> url.substring(MATRIX_TO_URL_BASE.length)
|
||||
clientBaseUrl != null && url.startsWith(clientBaseUrl) -> {
|
||||
when (PermalinkParser.parse(url)) {
|
||||
is PermalinkData.GroupLink -> url.substring(clientBaseUrl.length + GROUP_PATH.length)
|
||||
is PermalinkData.RoomLink -> url.substring(clientBaseUrl.length + ROOM_PATH.length)
|
||||
is PermalinkData.UserLink -> url.substring(clientBaseUrl.length + USER_PATH.length)
|
||||
else -> null
|
||||
is PermalinkData.RoomLink -> url.substring(clientBaseUrl.length + ROOM_PATH.length)
|
||||
is PermalinkData.UserLink -> url.substring(clientBaseUrl.length + USER_PATH.length)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
else -> null
|
||||
else -> null
|
||||
}
|
||||
?.substringBeforeLast("?")
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ internal class PermalinkFactory @Inject constructor(
|
|||
fun createMentionSpanTemplate(type: PermalinkService.SpanTemplateType, forceMatrixTo: Boolean): String {
|
||||
return buildString {
|
||||
when (type) {
|
||||
HTML -> append(MENTION_SPAN_TO_HTML_TEMPLATE_BEGIN)
|
||||
HTML -> append(MENTION_SPAN_TO_HTML_TEMPLATE_BEGIN)
|
||||
MARKDOWN -> append(MENTION_SPAN_TO_MD_TEMPLATE_BEGIN)
|
||||
}
|
||||
append(baseUrl(forceMatrixTo))
|
||||
|
@ -119,7 +119,7 @@ internal class PermalinkFactory @Inject constructor(
|
|||
append(USER_PATH)
|
||||
}
|
||||
when (type) {
|
||||
HTML -> append(MENTION_SPAN_TO_HTML_TEMPLATE_END)
|
||||
HTML -> append(MENTION_SPAN_TO_HTML_TEMPLATE_END)
|
||||
MARKDOWN -> append(MENTION_SPAN_TO_MD_TEMPLATE_END)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ internal class DefaultAddThreePidTask @Inject constructor(
|
|||
|
||||
override suspend fun execute(params: Params) {
|
||||
when (params.threePid) {
|
||||
is ThreePid.Email -> addEmail(params.threePid)
|
||||
is ThreePid.Email -> addEmail(params.threePid)
|
||||
is ThreePid.Msisdn -> addMsisdn(params.threePid)
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue