matrix-sdk: Add more getters to the high level verification structs
This commit is contained in:
parent
0053d2a874
commit
8f03679935
4 changed files with 66 additions and 3 deletions
|
@ -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<CancelInfo> {
|
||||
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<SasVerification> for Verification {
|
||||
|
|
|
@ -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<CancelInfo> {
|
||||
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()
|
||||
|
|
|
@ -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<CancelInfo> {
|
||||
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 {
|
||||
|
|
|
@ -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<CancelInfo> {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue