crypto: Dispatch updates when we receive MAC events

This commit is contained in:
Damir Jelić 2021-06-29 10:03:53 +02:00
parent 53b3f54808
commit 304c89a56d

View file

@ -36,6 +36,7 @@ import org.matrix.android.sdk.internal.crypto.VerificationRequest
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationCancel import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationCancel
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationDone import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationDone
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationKey import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationKey
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationMac
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationRequest import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationRequest
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationStart import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationStart
import org.matrix.android.sdk.internal.session.SessionScope import org.matrix.android.sdk.internal.session.SessionScope
@ -114,7 +115,7 @@ constructor(
EventType.KEY_VERIFICATION_CANCEL -> onCancel(event) EventType.KEY_VERIFICATION_CANCEL -> onCancel(event)
EventType.KEY_VERIFICATION_ACCEPT -> {} EventType.KEY_VERIFICATION_ACCEPT -> {}
EventType.KEY_VERIFICATION_KEY -> onKey(event) EventType.KEY_VERIFICATION_KEY -> onKey(event)
EventType.KEY_VERIFICATION_MAC -> {} EventType.KEY_VERIFICATION_MAC -> onMac(event)
EventType.KEY_VERIFICATION_READY -> {} EventType.KEY_VERIFICATION_READY -> {}
EventType.KEY_VERIFICATION_DONE -> onDone(event) EventType.KEY_VERIFICATION_DONE -> onDone(event)
MessageType.MSGTYPE_VERIFICATION_REQUEST -> onRequest(event) MessageType.MSGTYPE_VERIFICATION_REQUEST -> onRequest(event)
@ -182,6 +183,14 @@ constructor(
getAndDispatch(sender, flowId) getAndDispatch(sender, flowId)
} }
private fun onMac(event: Event) {
val content = event.getClearContent().toModel<KeyVerificationMac>() ?: return
val flowId = content.transactionId ?: return
val sender = event.senderId ?: return
getAndDispatch(sender, flowId)
}
private fun onRequest(event: Event) { private fun onRequest(event: Event) {
val content = event.getClearContent().toModel<KeyVerificationRequest>() ?: return val content = event.getClearContent().toModel<KeyVerificationRequest>() ?: return
val flowId = content.transactionId val flowId = content.transactionId