This commit is contained in:
Valere 2019-12-30 20:18:08 +01:00
parent 3c4506cb58
commit 935b3d7f3f
5 changed files with 4 additions and 8 deletions

View File

@ -48,6 +48,5 @@ interface SasVerificationTransaction {
*/ */
fun userHasVerifiedShortCode() fun userHasVerifiedShortCode()
fun shortCodeDoNotMatch() fun shortCodeDoNotMatch()
} }

View File

@ -25,7 +25,7 @@ import im.vector.matrix.android.internal.crypto.verification.VerificationInfoRea
@JsonClass(generateAdapter = true) @JsonClass(generateAdapter = true)
internal data class KeyVerificationReady( internal data class KeyVerificationReady(
@Json(name = "from_device") override val fromDevice: String?, @Json(name = "from_device") override val fromDevice: String?,
//TODO add qr? // TODO add qr?
@Json(name = "methods") override val methods: List<String>? = listOf(KeyVerificationStart.VERIF_METHOD_SAS), @Json(name = "methods") override val methods: List<String>? = listOf(KeyVerificationStart.VERIF_METHOD_SAS),
@Json(name = "transaction_id") override var transactionID: String? = null @Json(name = "transaction_id") override var transactionID: String? = null
) : SendToDeviceObject, VerificationInfoReady { ) : SendToDeviceObject, VerificationInfoReady {

View File

@ -80,7 +80,6 @@ internal class DefaultSasVerificationService @Inject constructor(
*/ */
private val pendingRequests = HashMap<String, ArrayList<PendingVerificationRequest>>() private val pendingRequests = HashMap<String, ArrayList<PendingVerificationRequest>>()
// Event received from the sync // Event received from the sync
fun onToDeviceEvent(event: Event) { fun onToDeviceEvent(event: Event) {
GlobalScope.launch(coroutineDispatchers.crypto) { GlobalScope.launch(coroutineDispatchers.crypto) {
@ -184,7 +183,6 @@ internal class DefaultSasVerificationService @Inject constructor(
} }
} }
private fun dispatchRequestAdded(tx: PendingVerificationRequest) { private fun dispatchRequestAdded(tx: PendingVerificationRequest) {
uiHandler.post { uiHandler.post {
listeners.forEach { listeners.forEach {
@ -756,14 +754,14 @@ internal class DefaultSasVerificationService @Inject constructor(
override fun readyPendingVerificationInDMs(otherUserId: String, roomId: String, transactionId: String) { override fun readyPendingVerificationInDMs(otherUserId: String, roomId: String, transactionId: String) {
// Let's find the related request // Let's find the related request
getExistingVerificationRequest(otherUserId)?.find { it.transactionId == transactionId }?.let { getExistingVerificationRequest(otherUserId)?.find { it.transactionId == transactionId }?.let {
//we need to send a ready event, with matching methods // we need to send a ready event, with matching methods
val transport = sasTransportRoomMessageFactory.createTransport(roomId, cryptoService, null) val transport = sasTransportRoomMessageFactory.createTransport(roomId, cryptoService, null)
val methods = it.requestInfo?.methods?.intersect(listOf(KeyVerificationStart.VERIF_METHOD_SAS))?.toList() val methods = it.requestInfo?.methods?.intersect(listOf(KeyVerificationStart.VERIF_METHOD_SAS))?.toList()
if (methods.isNullOrEmpty()) { if (methods.isNullOrEmpty()) {
Timber.i("Cannot ready this request, no common methods found txId:$transactionId") Timber.i("Cannot ready this request, no common methods found txId:$transactionId")
return@let return@let
} }
//TODO this is not yet related to a transaction, maybe we should use another method like for cancel? // TODO this is not yet related to a transaction, maybe we should use another method like for cancel?
val readyMsg = transport.createReady(transactionId, credentials.deviceId ?: "", methods) val readyMsg = transport.createReady(transactionId, credentials.deviceId ?: "", methods)
transport.sendToOther(EventType.KEY_VERIFICATION_READY, readyMsg, transport.sendToOther(EventType.KEY_VERIFICATION_READY, readyMsg,
SasVerificationTxState.None, SasVerificationTxState.None,

View File

@ -59,6 +59,5 @@ internal interface SasTransport {
fun createMac(tid: String, mac: Map<String, String>, keys: String): VerificationInfoMac fun createMac(tid: String, mac: Map<String, String>, keys: String): VerificationInfoMac
fun createReady(tid: String, fromDevice: String, methods: List<String>): VerificationInfoReady fun createReady(tid: String, fromDevice: String, methods: List<String>): VerificationInfoReady
} }

View File

@ -84,7 +84,7 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
viewModel.requestLiveData.observe(this, Observer { viewModel.requestLiveData.observe(viewLifecycleOwner, Observer {
it.peekContent().let { va -> it.peekContent().let { va ->
when (va) { when (va) {
is Success -> { is Success -> {