mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Also cancel pending request on back
This commit is contained in:
parent
3b62402cfe
commit
fcd290410e
3 changed files with 18 additions and 0 deletions
|
@ -60,6 +60,8 @@ interface VerificationService {
|
|||
roomId: String,
|
||||
localId: String? = LocalEcho.createLocalEchoId()): PendingVerificationRequest
|
||||
|
||||
fun cancelVerificationRequest(request: PendingVerificationRequest)
|
||||
|
||||
/**
|
||||
* Request a key verification from another user using toDevice events.
|
||||
*/
|
||||
|
|
|
@ -1102,6 +1102,18 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
return verificationRequest
|
||||
}
|
||||
|
||||
override fun cancelVerificationRequest(request: PendingVerificationRequest) {
|
||||
if (request.roomId != null) {
|
||||
val transport = verificationTransportRoomMessageFactory.createTransport(request.roomId, null)
|
||||
transport.cancelTransaction(request.transactionId ?: "", request.otherUserId, null, CancelCode.User)
|
||||
} else {
|
||||
val transport = verificationTransportToDeviceFactory.createTransport(null)
|
||||
request.targetDevices?.forEach { deviceId ->
|
||||
transport.cancelTransaction(request.transactionId ?: "", request.otherUserId, deviceId, CancelCode.User)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun requestKeyVerification(methods: List<VerificationMethod>, otherUserId: String, otherDevices: List<String>?): PendingVerificationRequest {
|
||||
// TODO refactor this with the DM one
|
||||
Timber.i("## Requesting verification to user: $otherUserId with device list $otherDevices")
|
||||
|
|
|
@ -149,6 +149,10 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
|
|||
}
|
||||
|
||||
fun confirmCancel() = withState { state ->
|
||||
session.cryptoService()
|
||||
.verificationService().getExistingVerificationRequest(state.otherUserMxItem?.id ?: "", state.transactionId)?.let {
|
||||
session.cryptoService().verificationService().cancelVerificationRequest(it)
|
||||
}
|
||||
session.cryptoService()
|
||||
.verificationService()
|
||||
.getExistingTransaction(state.otherUserMxItem?.id ?: "", state.transactionId ?: "")
|
||||
|
|
Loading…
Reference in a new issue