crypto: Expose some SAS methods publicly.

master
Damir Jelić 2020-07-28 16:24:45 +02:00
parent a6fa9f99fd
commit 7f2df68d62
2 changed files with 24 additions and 2 deletions

View File

@ -28,7 +28,7 @@ use super::store::memorystore::MemoryStore;
#[cfg(feature = "sqlite-cryptostore")]
use super::store::sqlite::SqliteStore;
use super::{device::Device, store::Result as StoreResult, CryptoStore};
use crate::verification::VerificationMachine;
use crate::verification::{Sas, VerificationMachine};
use matrix_sdk_common::events::{
forwarded_room_key::ForwardedRoomKeyEventContent, room::encrypted::EncryptedEventContent,
@ -1067,6 +1067,21 @@ impl OlmMachine {
}
}
/// Get the to-device requests that need to be sent out.
pub fn outgoing_to_device_requests(&self) -> Vec<ToDeviceRequest> {
self.verification_machine.outgoing_to_device_requests()
}
/// Mark an outgoing to-device requests as sent.
pub fn mark_to_device_request_as_sent(&self, request_id: &str) {
self.verification_machine.mark_requests_as_sent(request_id);
}
/// Get a `Sas` verification object with the given flow id.
pub fn get_verification(&self, flow_id: &str) -> Option<Sas> {
self.verification_machine.get_sas(flow_id)
}
/// Handle a sync response and update the internal state of the Olm machine.
///
/// This will decrypt to-device events but will not touch events in the room

View File

@ -49,7 +49,7 @@ impl VerificationMachine {
}
}
fn get_sas(&self, transaction_id: &str) -> Option<Sas> {
pub fn get_sas(&self, transaction_id: &str) -> Option<Sas> {
self.verifications.get(transaction_id).map(|s| s.clone())
}
@ -97,6 +97,13 @@ impl VerificationMachine {
self.outgoing_to_device_messages.remove(uuid);
}
pub fn outgoing_to_device_requests(&self) -> Vec<ToDeviceRequest> {
self.outgoing_to_device_messages
.iter()
.map(|r| r.clone())
.collect()
}
pub async fn receive_event(
&self,
event: &mut AnyToDeviceEvent,