mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-01 13:58:32 +03:00
rust: Bump the rust-sdk version
This commit is contained in:
parent
2167564812
commit
71cc38fa78
3 changed files with 56 additions and 48 deletions
|
@ -29,11 +29,11 @@ features = ["lax_deserialize"]
|
||||||
|
|
||||||
[dependencies.matrix-sdk-common]
|
[dependencies.matrix-sdk-common]
|
||||||
git = "https://github.com/matrix-org/matrix-rust-sdk/"
|
git = "https://github.com/matrix-org/matrix-rust-sdk/"
|
||||||
rev = "a628e84b63f6b761af383655e00f544ef6a09082"
|
rev = "8494f105837af824f4637c05e9e01b0854d7109b"
|
||||||
|
|
||||||
[dependencies.matrix-sdk-crypto]
|
[dependencies.matrix-sdk-crypto]
|
||||||
git = "https://github.com/matrix-org/matrix-rust-sdk/"
|
git = "https://github.com/matrix-org/matrix-rust-sdk/"
|
||||||
rev = "a628e84b63f6b761af383655e00f544ef6a09082"
|
rev = "8494f105837af824f4637c05e9e01b0854d7109b"
|
||||||
features = ["sled_cryptostore", "qrcode", "backups_v1"]
|
features = ["sled_cryptostore", "qrcode", "backups_v1"]
|
||||||
|
|
||||||
[dependencies.tokio]
|
[dependencies.tokio]
|
||||||
|
@ -43,7 +43,7 @@ features = ["rt-multi-thread"]
|
||||||
|
|
||||||
[dependencies.ruma]
|
[dependencies.ruma]
|
||||||
git = "https://github.com/ruma/ruma"
|
git = "https://github.com/ruma/ruma"
|
||||||
rev = "ac6ecc3e5"
|
rev = "6c4892664"
|
||||||
features = ["client-api-c"]
|
features = ["client-api-c"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|
|
@ -2,6 +2,7 @@ use std::{
|
||||||
collections::{BTreeMap, HashMap},
|
collections::{BTreeMap, HashMap},
|
||||||
convert::{TryFrom, TryInto},
|
convert::{TryFrom, TryInto},
|
||||||
io::Cursor,
|
io::Cursor,
|
||||||
|
ops::Deref,
|
||||||
};
|
};
|
||||||
|
|
||||||
use base64::{decode_config, encode, STANDARD_NO_PAD};
|
use base64::{decode_config, encode, STANDARD_NO_PAD};
|
||||||
|
@ -77,7 +78,7 @@ impl OlmMachine {
|
||||||
///
|
///
|
||||||
/// * `path` - The path where the state of the machine should be persisted.
|
/// * `path` - The path where the state of the machine should be persisted.
|
||||||
pub fn new(user_id: &str, device_id: &str, path: &str) -> Result<Self, CryptoStoreError> {
|
pub fn new(user_id: &str, device_id: &str, path: &str) -> Result<Self, CryptoStoreError> {
|
||||||
let user_id = UserId::try_from(user_id)?;
|
let user_id = Box::<UserId>::try_from(user_id)?;
|
||||||
let device_id = device_id.into();
|
let device_id = device_id.into();
|
||||||
let runtime = Runtime::new().expect("Couldn't create a tokio runtime");
|
let runtime = Runtime::new().expect("Couldn't create a tokio runtime");
|
||||||
|
|
||||||
|
@ -106,7 +107,7 @@ impl OlmMachine {
|
||||||
|
|
||||||
/// Get a cross signing user identity for the given user ID.
|
/// Get a cross signing user identity for the given user ID.
|
||||||
pub fn get_identity(&self, user_id: &str) -> Result<Option<UserIdentity>, CryptoStoreError> {
|
pub fn get_identity(&self, user_id: &str) -> Result<Option<UserIdentity>, CryptoStoreError> {
|
||||||
let user_id = UserId::try_from(user_id)?;
|
let user_id = Box::<UserId>::try_from(user_id)?;
|
||||||
|
|
||||||
Ok(
|
Ok(
|
||||||
if let Some(identity) = self.runtime.block_on(self.inner.get_identity(&user_id))? {
|
if let Some(identity) = self.runtime.block_on(self.inner.get_identity(&user_id))? {
|
||||||
|
@ -119,7 +120,7 @@ impl OlmMachine {
|
||||||
|
|
||||||
/// Check if a user identity is considered to be verified by us.
|
/// Check if a user identity is considered to be verified by us.
|
||||||
pub fn is_identity_verified(&self, user_id: &str) -> Result<bool, CryptoStoreError> {
|
pub fn is_identity_verified(&self, user_id: &str) -> Result<bool, CryptoStoreError> {
|
||||||
let user_id = UserId::try_from(user_id)?;
|
let user_id = Box::<UserId>::try_from(user_id)?;
|
||||||
|
|
||||||
Ok(
|
Ok(
|
||||||
if let Some(identity) = self.runtime.block_on(self.inner.get_identity(&user_id))? {
|
if let Some(identity) = self.runtime.block_on(self.inner.get_identity(&user_id))? {
|
||||||
|
@ -145,7 +146,7 @@ impl OlmMachine {
|
||||||
/// Returns a request that needs to be sent out for the user identity to be
|
/// Returns a request that needs to be sent out for the user identity to be
|
||||||
/// marked as verified.
|
/// marked as verified.
|
||||||
pub fn verify_identity(&self, user_id: &str) -> Result<SignatureUploadRequest, SignatureError> {
|
pub fn verify_identity(&self, user_id: &str) -> Result<SignatureUploadRequest, SignatureError> {
|
||||||
let user_id = UserId::try_from(user_id)?;
|
let user_id = Box::<UserId>::try_from(user_id)?;
|
||||||
|
|
||||||
let user_identity = self.runtime.block_on(self.inner.get_identity(&user_id))?;
|
let user_identity = self.runtime.block_on(self.inner.get_identity(&user_id))?;
|
||||||
|
|
||||||
|
@ -172,7 +173,7 @@ impl OlmMachine {
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
device_id: &str,
|
device_id: &str,
|
||||||
) -> Result<Option<Device>, CryptoStoreError> {
|
) -> Result<Option<Device>, CryptoStoreError> {
|
||||||
let user_id = UserId::try_from(user_id)?;
|
let user_id = Box::<UserId>::try_from(user_id)?;
|
||||||
|
|
||||||
Ok(self
|
Ok(self
|
||||||
.runtime
|
.runtime
|
||||||
|
@ -198,7 +199,7 @@ impl OlmMachine {
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
device_id: &str,
|
device_id: &str,
|
||||||
) -> Result<SignatureUploadRequest, SignatureError> {
|
) -> Result<SignatureUploadRequest, SignatureError> {
|
||||||
let user_id = UserId::try_from(user_id)?;
|
let user_id = Box::<UserId>::try_from(user_id)?;
|
||||||
let device = self
|
let device = self
|
||||||
.runtime
|
.runtime
|
||||||
.block_on(self.inner.get_device(&user_id, device_id.into()))?;
|
.block_on(self.inner.get_device(&user_id, device_id.into()))?;
|
||||||
|
@ -219,7 +220,7 @@ impl OlmMachine {
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
device_id: &str,
|
device_id: &str,
|
||||||
) -> Result<(), CryptoStoreError> {
|
) -> Result<(), CryptoStoreError> {
|
||||||
let user_id = UserId::try_from(user_id)?;
|
let user_id = Box::<UserId>::try_from(user_id)?;
|
||||||
|
|
||||||
let device = self
|
let device = self
|
||||||
.runtime
|
.runtime
|
||||||
|
@ -239,7 +240,7 @@ impl OlmMachine {
|
||||||
///
|
///
|
||||||
/// * `user_id` - The id of the device owner.
|
/// * `user_id` - The id of the device owner.
|
||||||
pub fn get_user_devices(&self, user_id: &str) -> Result<Vec<Device>, CryptoStoreError> {
|
pub fn get_user_devices(&self, user_id: &str) -> Result<Vec<Device>, CryptoStoreError> {
|
||||||
let user_id = UserId::try_from(user_id)?;
|
let user_id = Box::<UserId>::try_from(user_id)?;
|
||||||
|
|
||||||
Ok(self
|
Ok(self
|
||||||
.runtime
|
.runtime
|
||||||
|
@ -378,13 +379,15 @@ impl OlmMachine {
|
||||||
///
|
///
|
||||||
/// `users` - The users that should be queued up for a key query.
|
/// `users` - The users that should be queued up for a key query.
|
||||||
pub fn update_tracked_users(&self, users: Vec<String>) {
|
pub fn update_tracked_users(&self, users: Vec<String>) {
|
||||||
let users: Vec<UserId> = users
|
let users: Vec<Box<UserId>> = users
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|u| UserId::try_from(u).ok())
|
.filter_map(|u| Box::<UserId>::try_from(u).ok())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
self.runtime
|
self.runtime.block_on(
|
||||||
.block_on(self.inner.update_tracked_users(users.iter()));
|
self.inner
|
||||||
|
.update_tracked_users(users.iter().map(Deref::deref)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if the given user is considered to be tracked.
|
/// Check if the given user is considered to be tracked.
|
||||||
|
@ -392,7 +395,7 @@ impl OlmMachine {
|
||||||
/// A user can be marked for tracking using the
|
/// A user can be marked for tracking using the
|
||||||
/// [`OlmMachine::update_tracked_users()`] method.
|
/// [`OlmMachine::update_tracked_users()`] method.
|
||||||
pub fn is_user_tracked(&self, user_id: &str) -> Result<bool, CryptoStoreError> {
|
pub fn is_user_tracked(&self, user_id: &str) -> Result<bool, CryptoStoreError> {
|
||||||
let user_id = UserId::try_from(user_id)?;
|
let user_id = Box::<UserId>::try_from(user_id)?;
|
||||||
Ok(self.inner.tracked_users().contains(&user_id))
|
Ok(self.inner.tracked_users().contains(&user_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,14 +417,17 @@ impl OlmMachine {
|
||||||
&self,
|
&self,
|
||||||
users: Vec<String>,
|
users: Vec<String>,
|
||||||
) -> Result<Option<Request>, CryptoStoreError> {
|
) -> Result<Option<Request>, CryptoStoreError> {
|
||||||
let users: Vec<UserId> = users
|
let users: Vec<Box<UserId>> = users
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|u| UserId::try_from(u).ok())
|
.filter_map(|u| Box::<UserId>::try_from(u).ok())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Ok(self
|
Ok(self
|
||||||
.runtime
|
.runtime
|
||||||
.block_on(self.inner.get_missing_sessions(users.iter()))?
|
.block_on(
|
||||||
|
self.inner
|
||||||
|
.get_missing_sessions(users.iter().map(Deref::deref)),
|
||||||
|
)?
|
||||||
.map(|r| r.into()))
|
.map(|r| r.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,15 +453,15 @@ impl OlmMachine {
|
||||||
room_id: &str,
|
room_id: &str,
|
||||||
users: Vec<String>,
|
users: Vec<String>,
|
||||||
) -> Result<Vec<Request>, CryptoStoreError> {
|
) -> Result<Vec<Request>, CryptoStoreError> {
|
||||||
let users: Vec<UserId> = users
|
let users: Vec<Box<UserId>> = users
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|u| UserId::try_from(u).ok())
|
.filter_map(|u| Box::<UserId>::try_from(u).ok())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let room_id = RoomId::try_from(room_id)?;
|
let room_id = Box::<RoomId>::try_from(room_id)?;
|
||||||
let requests = self.runtime.block_on(self.inner.share_group_session(
|
let requests = self.runtime.block_on(self.inner.share_group_session(
|
||||||
&room_id,
|
&room_id,
|
||||||
users.iter(),
|
users.iter().map(Deref::deref),
|
||||||
EncryptionSettings::default(),
|
EncryptionSettings::default(),
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
|
@ -501,7 +507,7 @@ impl OlmMachine {
|
||||||
event_type: &str,
|
event_type: &str,
|
||||||
content: &str,
|
content: &str,
|
||||||
) -> Result<String, CryptoStoreError> {
|
) -> Result<String, CryptoStoreError> {
|
||||||
let room_id = RoomId::try_from(room_id)?;
|
let room_id = Box::<RoomId>::try_from(room_id)?;
|
||||||
let content: Box<RawValue> = serde_json::from_str(content)?;
|
let content: Box<RawValue> = serde_json::from_str(content)?;
|
||||||
|
|
||||||
let content = AnyMessageEventContent::from_parts(event_type, &content)?;
|
let content = AnyMessageEventContent::from_parts(event_type, &content)?;
|
||||||
|
@ -537,7 +543,7 @@ impl OlmMachine {
|
||||||
}
|
}
|
||||||
|
|
||||||
let event: SyncMessageEvent<RoomEncryptedEventContent> = serde_json::from_str(event)?;
|
let event: SyncMessageEvent<RoomEncryptedEventContent> = serde_json::from_str(event)?;
|
||||||
let room_id = RoomId::try_from(room_id)?;
|
let room_id = Box::<RoomId>::try_from(room_id)?;
|
||||||
|
|
||||||
let decrypted = self
|
let decrypted = self
|
||||||
.runtime
|
.runtime
|
||||||
|
@ -580,7 +586,7 @@ impl OlmMachine {
|
||||||
room_id: &str,
|
room_id: &str,
|
||||||
) -> Result<KeyRequestPair, DecryptionError> {
|
) -> Result<KeyRequestPair, DecryptionError> {
|
||||||
let event: SyncMessageEvent<RoomEncryptedEventContent> = serde_json::from_str(event)?;
|
let event: SyncMessageEvent<RoomEncryptedEventContent> = serde_json::from_str(event)?;
|
||||||
let room_id = RoomId::try_from(room_id)?;
|
let room_id = Box::<RoomId>::try_from(room_id)?;
|
||||||
|
|
||||||
let (cancel, request) = self
|
let (cancel, request) = self
|
||||||
.runtime
|
.runtime
|
||||||
|
@ -698,7 +704,7 @@ impl OlmMachine {
|
||||||
/// Discard the currently active room key for the given room if there is
|
/// Discard the currently active room key for the given room if there is
|
||||||
/// one.
|
/// one.
|
||||||
pub fn discard_room_key(&self, room_id: &str) -> Result<(), CryptoStoreError> {
|
pub fn discard_room_key(&self, room_id: &str) -> Result<(), CryptoStoreError> {
|
||||||
let room_id = RoomId::try_from(room_id)?;
|
let room_id = Box::<RoomId>::try_from(room_id)?;
|
||||||
|
|
||||||
self.runtime
|
self.runtime
|
||||||
.block_on(self.inner.invalidate_group_session(&room_id))?;
|
.block_on(self.inner.invalidate_group_session(&room_id))?;
|
||||||
|
@ -713,7 +719,7 @@ impl OlmMachine {
|
||||||
/// * `user_id` - The ID of the user for which we would like to fetch the
|
/// * `user_id` - The ID of the user for which we would like to fetch the
|
||||||
/// verification requests.
|
/// verification requests.
|
||||||
pub fn get_verification_requests(&self, user_id: &str) -> Vec<VerificationRequest> {
|
pub fn get_verification_requests(&self, user_id: &str) -> Vec<VerificationRequest> {
|
||||||
let user_id = if let Ok(user_id) = UserId::try_from(user_id) {
|
let user_id = if let Ok(user_id) = Box::<UserId>::try_from(user_id) {
|
||||||
user_id
|
user_id
|
||||||
} else {
|
} else {
|
||||||
return vec![];
|
return vec![];
|
||||||
|
@ -740,7 +746,7 @@ impl OlmMachine {
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
flow_id: &str,
|
flow_id: &str,
|
||||||
) -> Option<VerificationRequest> {
|
) -> Option<VerificationRequest> {
|
||||||
let user_id = UserId::try_from(user_id).ok()?;
|
let user_id = Box::<UserId>::try_from(user_id).ok()?;
|
||||||
|
|
||||||
self.inner
|
self.inner
|
||||||
.get_verification_request(&user_id, flow_id)
|
.get_verification_request(&user_id, flow_id)
|
||||||
|
@ -767,7 +773,7 @@ impl OlmMachine {
|
||||||
flow_id: &str,
|
flow_id: &str,
|
||||||
methods: Vec<String>,
|
methods: Vec<String>,
|
||||||
) -> Option<OutgoingVerificationRequest> {
|
) -> Option<OutgoingVerificationRequest> {
|
||||||
let user_id = UserId::try_from(user_id).ok()?;
|
let user_id = Box::<UserId>::try_from(user_id).ok()?;
|
||||||
let methods = methods.into_iter().map(VerificationMethod::from).collect();
|
let methods = methods.into_iter().map(VerificationMethod::from).collect();
|
||||||
|
|
||||||
if let Some(verification) = self.inner.get_verification_request(&user_id, flow_id) {
|
if let Some(verification) = self.inner.get_verification_request(&user_id, flow_id) {
|
||||||
|
@ -791,7 +797,7 @@ impl OlmMachine {
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
methods: Vec<String>,
|
methods: Vec<String>,
|
||||||
) -> Result<Option<String>, CryptoStoreError> {
|
) -> Result<Option<String>, CryptoStoreError> {
|
||||||
let user_id = UserId::try_from(user_id)?;
|
let user_id = Box::<UserId>::try_from(user_id)?;
|
||||||
|
|
||||||
let identity = self.runtime.block_on(self.inner.get_identity(&user_id))?;
|
let identity = self.runtime.block_on(self.inner.get_identity(&user_id))?;
|
||||||
|
|
||||||
|
@ -834,9 +840,9 @@ impl OlmMachine {
|
||||||
event_id: &str,
|
event_id: &str,
|
||||||
methods: Vec<String>,
|
methods: Vec<String>,
|
||||||
) -> Result<Option<VerificationRequest>, CryptoStoreError> {
|
) -> Result<Option<VerificationRequest>, CryptoStoreError> {
|
||||||
let user_id = UserId::try_from(user_id)?;
|
let user_id = Box::<UserId>::try_from(user_id)?;
|
||||||
let event_id = EventId::try_from(event_id)?;
|
let event_id = Box::<EventId>::try_from(event_id)?;
|
||||||
let room_id = RoomId::try_from(room_id)?;
|
let room_id = Box::<RoomId>::try_from(room_id)?;
|
||||||
|
|
||||||
let identity = self.runtime.block_on(self.inner.get_identity(&user_id))?;
|
let identity = self.runtime.block_on(self.inner.get_identity(&user_id))?;
|
||||||
|
|
||||||
|
@ -872,7 +878,7 @@ impl OlmMachine {
|
||||||
device_id: &str,
|
device_id: &str,
|
||||||
methods: Vec<String>,
|
methods: Vec<String>,
|
||||||
) -> Result<Option<RequestVerificationResult>, CryptoStoreError> {
|
) -> Result<Option<RequestVerificationResult>, CryptoStoreError> {
|
||||||
let user_id = UserId::try_from(user_id)?;
|
let user_id = Box::<UserId>::try_from(user_id)?;
|
||||||
|
|
||||||
let methods = methods.into_iter().map(VerificationMethod::from).collect();
|
let methods = methods.into_iter().map(VerificationMethod::from).collect();
|
||||||
|
|
||||||
|
@ -933,7 +939,8 @@ impl OlmMachine {
|
||||||
///
|
///
|
||||||
/// * `flow_id` - The ID that uniquely identifies the verification flow.
|
/// * `flow_id` - The ID that uniquely identifies the verification flow.
|
||||||
pub fn get_verification(&self, user_id: &str, flow_id: &str) -> Option<Verification> {
|
pub fn get_verification(&self, user_id: &str, flow_id: &str) -> Option<Verification> {
|
||||||
let user_id = UserId::try_from(user_id).ok()?;
|
let user_id = Box::<UserId>::try_from(user_id).ok()?;
|
||||||
|
|
||||||
self.inner
|
self.inner
|
||||||
.get_verification(&user_id, flow_id)
|
.get_verification(&user_id, flow_id)
|
||||||
.map(|v| match v {
|
.map(|v| match v {
|
||||||
|
@ -963,7 +970,7 @@ impl OlmMachine {
|
||||||
flow_id: &str,
|
flow_id: &str,
|
||||||
cancel_code: &str,
|
cancel_code: &str,
|
||||||
) -> Option<OutgoingVerificationRequest> {
|
) -> Option<OutgoingVerificationRequest> {
|
||||||
let user_id = UserId::try_from(user_id).ok()?;
|
let user_id = Box::<UserId>::try_from(user_id).ok()?;
|
||||||
|
|
||||||
if let Some(request) = self.inner.get_verification_request(&user_id, flow_id) {
|
if let Some(request) = self.inner.get_verification_request(&user_id, flow_id) {
|
||||||
request.cancel().map(|r| r.into())
|
request.cancel().map(|r| r.into())
|
||||||
|
@ -998,7 +1005,7 @@ impl OlmMachine {
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
flow_id: &str,
|
flow_id: &str,
|
||||||
) -> Result<Option<ConfirmVerificationResult>, CryptoStoreError> {
|
) -> Result<Option<ConfirmVerificationResult>, CryptoStoreError> {
|
||||||
let user_id = UserId::try_from(user_id)?;
|
let user_id = Box::<UserId>::try_from(user_id)?;
|
||||||
|
|
||||||
Ok(
|
Ok(
|
||||||
if let Some(verification) = self.inner.get_verification(&user_id, flow_id) {
|
if let Some(verification) = self.inner.get_verification(&user_id, flow_id) {
|
||||||
|
@ -1041,7 +1048,7 @@ impl OlmMachine {
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
flow_id: &str,
|
flow_id: &str,
|
||||||
) -> Result<Option<QrCode>, CryptoStoreError> {
|
) -> Result<Option<QrCode>, CryptoStoreError> {
|
||||||
let user_id = UserId::try_from(user_id)?;
|
let user_id = Box::<UserId>::try_from(user_id)?;
|
||||||
|
|
||||||
if let Some(verification) = self.inner.get_verification_request(&user_id, flow_id) {
|
if let Some(verification) = self.inner.get_verification_request(&user_id, flow_id) {
|
||||||
Ok(self
|
Ok(self
|
||||||
|
@ -1072,7 +1079,7 @@ impl OlmMachine {
|
||||||
///
|
///
|
||||||
/// [start_qr_verification()]: #method.start_qr_verification
|
/// [start_qr_verification()]: #method.start_qr_verification
|
||||||
pub fn generate_qr_code(&self, user_id: &str, flow_id: &str) -> Option<String> {
|
pub fn generate_qr_code(&self, user_id: &str, flow_id: &str) -> Option<String> {
|
||||||
let user_id = UserId::try_from(user_id).ok()?;
|
let user_id = Box::<UserId>::try_from(user_id).ok()?;
|
||||||
self.inner
|
self.inner
|
||||||
.get_verification(&user_id, flow_id)
|
.get_verification(&user_id, flow_id)
|
||||||
.and_then(|v| v.qr_v1().and_then(|qr| qr.to_bytes().map(encode).ok()))
|
.and_then(|v| v.qr_v1().and_then(|qr| qr.to_bytes().map(encode).ok()))
|
||||||
|
@ -1095,7 +1102,7 @@ impl OlmMachine {
|
||||||
/// * `data` - The data that was extracted from the scanned QR code as an
|
/// * `data` - The data that was extracted from the scanned QR code as an
|
||||||
/// base64 encoded string, without padding.
|
/// base64 encoded string, without padding.
|
||||||
pub fn scan_qr_code(&self, user_id: &str, flow_id: &str, data: &str) -> Option<ScanResult> {
|
pub fn scan_qr_code(&self, user_id: &str, flow_id: &str, data: &str) -> Option<ScanResult> {
|
||||||
let user_id = UserId::try_from(user_id).ok()?;
|
let user_id = Box::<UserId>::try_from(user_id).ok()?;
|
||||||
let data = decode_config(data, STANDARD_NO_PAD).ok()?;
|
let data = decode_config(data, STANDARD_NO_PAD).ok()?;
|
||||||
let data = QrVerificationData::from_bytes(data).ok()?;
|
let data = QrVerificationData::from_bytes(data).ok()?;
|
||||||
|
|
||||||
|
@ -1134,7 +1141,7 @@ impl OlmMachine {
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
flow_id: &str,
|
flow_id: &str,
|
||||||
) -> Result<Option<StartSasResult>, CryptoStoreError> {
|
) -> Result<Option<StartSasResult>, CryptoStoreError> {
|
||||||
let user_id = UserId::try_from(user_id)?;
|
let user_id = Box::<UserId>::try_from(user_id)?;
|
||||||
|
|
||||||
Ok(
|
Ok(
|
||||||
if let Some(verification) = self.inner.get_verification_request(&user_id, flow_id) {
|
if let Some(verification) = self.inner.get_verification_request(&user_id, flow_id) {
|
||||||
|
@ -1169,7 +1176,7 @@ impl OlmMachine {
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
device_id: &str,
|
device_id: &str,
|
||||||
) -> Result<Option<StartSasResult>, CryptoStoreError> {
|
) -> Result<Option<StartSasResult>, CryptoStoreError> {
|
||||||
let user_id = UserId::try_from(user_id)?;
|
let user_id = Box::<UserId>::try_from(user_id)?;
|
||||||
|
|
||||||
Ok(
|
Ok(
|
||||||
if let Some(device) = self
|
if let Some(device) = self
|
||||||
|
@ -1201,7 +1208,8 @@ impl OlmMachine {
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
flow_id: &str,
|
flow_id: &str,
|
||||||
) -> Option<OutgoingVerificationRequest> {
|
) -> Option<OutgoingVerificationRequest> {
|
||||||
let user_id = UserId::try_from(user_id).ok()?;
|
let user_id = Box::<UserId>::try_from(user_id).ok()?;
|
||||||
|
|
||||||
self.inner
|
self.inner
|
||||||
.get_verification(&user_id, flow_id)
|
.get_verification(&user_id, flow_id)
|
||||||
.and_then(|s| s.sas_v1())
|
.and_then(|s| s.sas_v1())
|
||||||
|
@ -1222,7 +1230,7 @@ impl OlmMachine {
|
||||||
///
|
///
|
||||||
/// * `flow_id` - The ID that uniquely identifies the verification flow.
|
/// * `flow_id` - The ID that uniquely identifies the verification flow.
|
||||||
pub fn get_emoji_index(&self, user_id: &str, flow_id: &str) -> Option<Vec<i32>> {
|
pub fn get_emoji_index(&self, user_id: &str, flow_id: &str) -> Option<Vec<i32>> {
|
||||||
let user_id = UserId::try_from(user_id).ok()?;
|
let user_id = Box::<UserId>::try_from(user_id).ok()?;
|
||||||
|
|
||||||
self.inner
|
self.inner
|
||||||
.get_verification(&user_id, flow_id)
|
.get_verification(&user_id, flow_id)
|
||||||
|
@ -1247,7 +1255,7 @@ impl OlmMachine {
|
||||||
///
|
///
|
||||||
/// * `flow_id` - The ID that uniquely identifies the verification flow.
|
/// * `flow_id` - The ID that uniquely identifies the verification flow.
|
||||||
pub fn get_decimals(&self, user_id: &str, flow_id: &str) -> Option<Vec<i32>> {
|
pub fn get_decimals(&self, user_id: &str, flow_id: &str) -> Option<Vec<i32>> {
|
||||||
let user_id = UserId::try_from(user_id).ok()?;
|
let user_id = Box::<UserId>::try_from(user_id).ok()?;
|
||||||
|
|
||||||
self.inner
|
self.inner
|
||||||
.get_verification(&user_id, flow_id)
|
.get_verification(&user_id, flow_id)
|
||||||
|
|
|
@ -283,12 +283,12 @@ impl From<DeviceLists> for RumaDeviceLists {
|
||||||
changed: d
|
changed: d
|
||||||
.changed
|
.changed
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|u| UserId::try_from(u).ok())
|
.filter_map(|u| Box::<UserId>::try_from(u).ok())
|
||||||
.collect(),
|
.collect(),
|
||||||
left: d
|
left: d
|
||||||
.left
|
.left
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|u| UserId::try_from(u).ok())
|
.filter_map(|u| Box::<UserId>::try_from(u).ok())
|
||||||
.collect(),
|
.collect(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue