mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-26 15:18:19 +08:00
Add RequestDeviceVerification method
This commit is contained in:
parent
466260bc6a
commit
3e116ad065
@ -45,6 +45,18 @@ interface VerificationService {
|
||||
|
||||
fun getExistingVerificationRequestInRoom(roomId: String, tid: String?): PendingVerificationRequest?
|
||||
|
||||
|
||||
/**
|
||||
* Request an interactive verification to begin
|
||||
*
|
||||
* This sends out a m.key.verification.request event over to-device messaging to
|
||||
* to this device.
|
||||
*
|
||||
* If no specific device should be verified, but we would like to request
|
||||
* verification from all our devices, use [requestSelfKeyVerification] instead.
|
||||
*/
|
||||
suspend fun requestDeviceVerification(methods: List<VerificationMethod>, otherUserId: String, otherDeviceId: String): PendingVerificationRequest?
|
||||
|
||||
/**
|
||||
* Request key verification with another user via room events (instead of the to-device API).
|
||||
*/
|
||||
|
@ -28,7 +28,6 @@ import org.matrix.android.sdk.internal.crypto.verification.prepareMethods
|
||||
import uniffi.olm.CryptoStoreException
|
||||
import uniffi.olm.OlmMachine
|
||||
import uniffi.olm.SignatureException
|
||||
import uniffi.olm.VerificationRequest
|
||||
import uniffi.olm.Device as InnerDevice
|
||||
|
||||
/** Class representing a device that supports E2EE in the Matrix world
|
||||
@ -71,10 +70,15 @@ internal class Device(
|
||||
val result = withContext(coroutineDispatchers.io) {
|
||||
machine.requestVerificationWithDevice(inner.userId, inner.deviceId, stringMethods)
|
||||
}
|
||||
|
||||
return if (result != null) {
|
||||
sender.sendVerificationRequest(result.request)
|
||||
result.verification
|
||||
VerificationRequest(
|
||||
machine = machine,
|
||||
inner = result.verification,
|
||||
sender = sender,
|
||||
coroutineDispatchers = coroutineDispatchers,
|
||||
listeners = listeners
|
||||
)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
@ -254,6 +254,14 @@ internal class RustVerificationService @Inject constructor(private val olmMachin
|
||||
return verification.toPendingVerificationRequest()
|
||||
}
|
||||
|
||||
|
||||
override suspend fun requestDeviceVerification(methods: List<VerificationMethod>, otherUserId: String, otherDeviceId: String): PendingVerificationRequest? {
|
||||
olmMachine.ensureUsersKeys(listOf(otherUserId))
|
||||
val otherDevice = olmMachine.getDevice(otherUserId, otherDeviceId)
|
||||
val verificationRequest = otherDevice?.requestVerification(methods)
|
||||
return verificationRequest?.toPendingVerificationRequest()
|
||||
}
|
||||
|
||||
override suspend fun readyPendingVerification(
|
||||
methods: List<VerificationMethod>,
|
||||
otherUserId: String,
|
||||
|
Loading…
Reference in New Issue
Block a user