mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-06 15:04:11 -04:00
Expose mechanism for registering to verification updates before actually accepting one
- allows handling remote cancellations on verification requests that have not yet been accepted
This commit is contained in:
committed by
Stefan Ceriu
parent
8cf0716db2
commit
3a34b03726
@@ -66,11 +66,10 @@ impl SessionVerificationController {
|
||||
*self.delegate.write().unwrap() = delegate;
|
||||
}
|
||||
|
||||
pub async fn accept_verification_request(
|
||||
&self,
|
||||
sender_id: String,
|
||||
flow_id: String,
|
||||
) -> Result<(), ClientError> {
|
||||
/// Set this particular request as the currently active one and register for events pertaining it.
|
||||
/// * `sender_id` - The user requesting verification.
|
||||
/// * `flow_id` - - The ID that uniquely identifies the verification flow.
|
||||
pub async fn acknowledge_verification_request(&self, sender_id: String, flow_id: String) {
|
||||
let sender_id = UserId::parse(sender_id.clone())?;
|
||||
|
||||
let verification_request = self
|
||||
@@ -79,9 +78,24 @@ impl SessionVerificationController {
|
||||
.await
|
||||
.ok_or(ClientError::new("Unknown session verification request"))?;
|
||||
|
||||
verification_request.accept().await?;
|
||||
*self.verification_request.write().unwrap() = Some(verification_request.clone());
|
||||
|
||||
*self.verification_request.write().unwrap() = Some(verification_request);
|
||||
RUNTIME.spawn(Self::listen_to_verification_request_changes(
|
||||
verification_request,
|
||||
self.sas_verification.clone(),
|
||||
self.delegate.clone(),
|
||||
));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Accept the previously acknowledged verification request
|
||||
pub async fn accept_verification_request(&self) -> Result<(), ClientError> {
|
||||
let verification_request = self.verification_request.read().unwrap().clone();
|
||||
|
||||
if let Some(verification_request) = verification_request {
|
||||
verification_request.accept().await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user