matrix-sdk: Add more getters to the high level verification structs
parent
0053d2a874
commit
8f03679935
|
@ -33,6 +33,7 @@ mod qrcode;
|
||||||
mod requests;
|
mod requests;
|
||||||
mod sas;
|
mod sas;
|
||||||
|
|
||||||
|
pub use matrix_sdk_base::crypto::{AcceptSettings, CancelInfo};
|
||||||
pub use qrcode::QrVerification;
|
pub use qrcode::QrVerification;
|
||||||
pub use requests::VerificationRequest;
|
pub use requests::VerificationRequest;
|
||||||
pub use sas::SasVerification;
|
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.
|
/// Get our own user id.
|
||||||
pub fn own_user_id(&self) -> &ruma::UserId {
|
pub fn own_user_id(&self) -> &ruma::UserId {
|
||||||
match self {
|
match self {
|
||||||
|
@ -105,6 +115,14 @@ impl Verification {
|
||||||
Verification::QrV1(v) => v.is_self_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 {
|
impl From<SasVerification> for Verification {
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
use matrix_sdk_base::crypto::{
|
use matrix_sdk_base::crypto::{
|
||||||
matrix_qrcode::{qrcode::QrCode, EncodingError},
|
matrix_qrcode::{qrcode::QrCode, EncodingError},
|
||||||
QrVerification as BaseQrVerification,
|
CancelInfo, QrVerification as BaseQrVerification,
|
||||||
};
|
};
|
||||||
use ruma::UserId;
|
use ruma::UserId;
|
||||||
|
|
||||||
|
@ -43,6 +43,23 @@ impl QrVerification {
|
||||||
self.inner.is_done()
|
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.
|
/// Has the verification been cancelled.
|
||||||
pub fn is_cancelled(&self) -> bool {
|
pub fn is_cancelled(&self) -> bool {
|
||||||
self.inner.is_cancelled()
|
self.inner.is_cancelled()
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// 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 ruma::events::key::verification::VerificationMethod;
|
||||||
|
|
||||||
use super::{QrVerification, SasVerification};
|
use super::{QrVerification, SasVerification};
|
||||||
|
@ -36,6 +36,12 @@ impl VerificationRequest {
|
||||||
self.inner.is_cancelled()
|
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.
|
/// Get our own user id.
|
||||||
pub fn own_user_id(&self) -> &ruma::UserId {
|
pub fn own_user_id(&self) -> &ruma::UserId {
|
||||||
self.inner.own_user_id()
|
self.inner.own_user_id()
|
||||||
|
@ -51,6 +57,11 @@ impl VerificationRequest {
|
||||||
self.inner.is_ready()
|
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
|
/// Get the user id of the other user participating in this verification
|
||||||
/// flow.
|
/// flow.
|
||||||
pub fn other_user_id(&self) -> &ruma::UserId {
|
pub fn other_user_id(&self) -> &ruma::UserId {
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// 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 ruma::UserId;
|
||||||
|
|
||||||
use crate::{error::Result, Client};
|
use crate::{error::Result, Client};
|
||||||
|
@ -121,6 +121,17 @@ impl SasVerification {
|
||||||
self.inner.can_be_presented()
|
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.
|
/// Is the verification process canceled.
|
||||||
pub fn is_cancelled(&self) -> bool {
|
pub fn is_cancelled(&self) -> bool {
|
||||||
self.inner.is_cancelled()
|
self.inner.is_cancelled()
|
||||||
|
@ -145,4 +156,10 @@ impl SasVerification {
|
||||||
pub fn own_user_id(&self) -> &UserId {
|
pub fn own_user_id(&self) -> &UserId {
|
||||||
self.inner.user_id()
|
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 New Issue