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