diff --git a/matrix_sdk/src/verification/mod.rs b/matrix_sdk/src/verification/mod.rs index a742badf..80a21f2b 100644 --- a/matrix_sdk/src/verification/mod.rs +++ b/matrix_sdk/src/verification/mod.rs @@ -33,6 +33,7 @@ mod qrcode; mod requests; mod sas; +pub use matrix_sdk_base::crypto::{AcceptSettings, CancelInfo}; pub use qrcode::QrVerification; pub use requests::VerificationRequest; pub use sas::SasVerification; @@ -81,6 +82,15 @@ impl Verification { } } + /// Get info about the cancellation if the verification flow has been + /// cancelled. + pub fn cancel_info(&self) -> Option { + match self { + Verification::SasV1(s) => s.cancel_info(), + Verification::QrV1(q) => q.cancel_info(), + } + } + /// Get our own user id. pub fn own_user_id(&self) -> &ruma::UserId { match self { @@ -105,6 +115,14 @@ impl Verification { Verification::QrV1(v) => v.is_self_verification(), } } + + /// Did we initiate the verification flow. + pub fn we_started(&self) -> bool { + match self { + Verification::SasV1(s) => s.we_started(), + Verification::QrV1(q) => q.we_started(), + } + } } impl From for Verification { diff --git a/matrix_sdk/src/verification/qrcode.rs b/matrix_sdk/src/verification/qrcode.rs index f28d11b5..78b80e80 100644 --- a/matrix_sdk/src/verification/qrcode.rs +++ b/matrix_sdk/src/verification/qrcode.rs @@ -14,7 +14,7 @@ use matrix_sdk_base::crypto::{ matrix_qrcode::{qrcode::QrCode, EncodingError}, - QrVerification as BaseQrVerification, + CancelInfo, QrVerification as BaseQrVerification, }; use ruma::UserId; @@ -43,6 +43,23 @@ impl QrVerification { self.inner.is_done() } + /// Did we initiate the verification flow. + pub fn we_started(&self) -> bool { + self.inner.we_started() + } + + /// Get info about the cancellation if the verification flow has been + /// cancelled. + pub fn cancel_info(&self) -> Option { + self.inner.cancel_info() + } + + /// Get the user id of the other user participating in this verification + /// flow. + pub fn other_user_id(&self) -> &UserId { + self.inner.other_user_id() + } + /// Has the verification been cancelled. pub fn is_cancelled(&self) -> bool { self.inner.is_cancelled() diff --git a/matrix_sdk/src/verification/requests.rs b/matrix_sdk/src/verification/requests.rs index 5a94c7b9..b7b39485 100644 --- a/matrix_sdk/src/verification/requests.rs +++ b/matrix_sdk/src/verification/requests.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use matrix_sdk_base::crypto::VerificationRequest as BaseVerificationRequest; +use matrix_sdk_base::crypto::{CancelInfo, VerificationRequest as BaseVerificationRequest}; use ruma::events::key::verification::VerificationMethod; use super::{QrVerification, SasVerification}; @@ -36,6 +36,12 @@ impl VerificationRequest { self.inner.is_cancelled() } + /// Get info about the cancellation if the verification request has been + /// cancelled. + pub fn cancel_info(&self) -> Option { + self.inner.cancel_info() + } + /// Get our own user id. pub fn own_user_id(&self) -> &ruma::UserId { self.inner.own_user_id() @@ -51,6 +57,11 @@ impl VerificationRequest { self.inner.is_ready() } + /// Did we initiate the verification flow. + pub fn we_started(&self) -> bool { + self.inner.we_started() + } + /// Get the user id of the other user participating in this verification /// flow. pub fn other_user_id(&self) -> &ruma::UserId { diff --git a/matrix_sdk/src/verification/sas.rs b/matrix_sdk/src/verification/sas.rs index 76d1df92..3cb46641 100644 --- a/matrix_sdk/src/verification/sas.rs +++ b/matrix_sdk/src/verification/sas.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use matrix_sdk_base::crypto::{AcceptSettings, ReadOnlyDevice, Sas as BaseSas}; +use matrix_sdk_base::crypto::{AcceptSettings, CancelInfo, ReadOnlyDevice, Sas as BaseSas}; use ruma::UserId; use crate::{error::Result, Client}; @@ -121,6 +121,17 @@ impl SasVerification { self.inner.can_be_presented() } + /// Did we initiate the verification flow. + pub fn we_started(&self) -> bool { + self.inner.we_started() + } + + /// Get info about the cancellation if the verification flow has been + /// cancelled. + pub fn cancel_info(&self) -> Option { + self.inner.cancel_info() + } + /// Is the verification process canceled. pub fn is_cancelled(&self) -> bool { self.inner.is_cancelled() @@ -145,4 +156,10 @@ impl SasVerification { pub fn own_user_id(&self) -> &UserId { self.inner.user_id() } + + /// Get the user id of the other user participating in this verification + /// flow. + pub fn other_user_id(&self) -> &UserId { + self.inner.other_user_id() + } }