async_client: Replace the events with decrypted ones.
parent
abe13d7a2d
commit
485296bc34
|
@ -29,7 +29,6 @@ use reqwest::header::{HeaderValue, InvalidHeaderValue};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use ruma_api::{Endpoint, Outgoing};
|
use ruma_api::{Endpoint, Outgoing};
|
||||||
use ruma_client_api::Error as RumaClientError;
|
|
||||||
use ruma_events::collections::all::RoomEvent;
|
use ruma_events::collections::all::RoomEvent;
|
||||||
use ruma_events::room::message::MessageEventContent;
|
use ruma_events::room::message::MessageEventContent;
|
||||||
use ruma_events::EventResult;
|
use ruma_events::EventResult;
|
||||||
|
@ -404,13 +403,19 @@ impl AsyncClient {
|
||||||
.await
|
.await
|
||||||
};
|
};
|
||||||
|
|
||||||
let event = match decrypted_event {
|
if let Some(e) = decrypted_event {
|
||||||
Some(e) => Arc::new(e.clone()),
|
*event = e;
|
||||||
None => Arc::new(event.clone()),
|
}
|
||||||
};
|
|
||||||
|
|
||||||
let callbacks = {
|
let callbacks = {
|
||||||
let mut cb_futures = self.event_callbacks.lock().unwrap();
|
let mut cb_futures = self.event_callbacks.lock().unwrap();
|
||||||
|
|
||||||
|
let event = if !cb_futures.is_empty() {
|
||||||
|
Arc::new(event.clone())
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
let mut callbacks = Vec::new();
|
let mut callbacks = Vec::new();
|
||||||
|
|
||||||
for cb in &mut cb_futures.iter_mut() {
|
for cb in &mut cb_futures.iter_mut() {
|
||||||
|
|
|
@ -20,8 +20,8 @@ use std::result::Result as StdResult;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use super::error::{OlmError, Result, SignatureError, VerificationResult};
|
use super::error::{OlmError, Result, SignatureError, VerificationResult};
|
||||||
use super::memory_stores::GroupSessionStore;
|
use super::memory_stores::{GroupSessionStore, SessionStore};
|
||||||
use super::olm::{Account, InboundGroupSession};
|
use super::olm::{Account, InboundGroupSession, Session};
|
||||||
#[cfg(feature = "sqlite-cryptostore")]
|
#[cfg(feature = "sqlite-cryptostore")]
|
||||||
use super::store::sqlite::SqliteStore;
|
use super::store::sqlite::SqliteStore;
|
||||||
use super::store::MemoryStore;
|
use super::store::MemoryStore;
|
||||||
|
@ -69,7 +69,9 @@ pub struct OlmMachine {
|
||||||
/// Store for the encryption keys.
|
/// Store for the encryption keys.
|
||||||
/// Persists all the encrytpion keys so a client can resume the session
|
/// Persists all the encrytpion keys so a client can resume the session
|
||||||
/// without the need to create new keys.
|
/// without the need to create new keys.
|
||||||
store: Box<dyn CryptoStore>,
|
// store: Box<dyn CryptoStore>,
|
||||||
|
/// A cache of all the Olm sessions we know about.
|
||||||
|
sessions: SessionStore,
|
||||||
/// A cache of all the inbound group sessions we know about.
|
/// A cache of all the inbound group sessions we know about.
|
||||||
inbound_group_sessions: GroupSessionStore,
|
inbound_group_sessions: GroupSessionStore,
|
||||||
}
|
}
|
||||||
|
@ -87,7 +89,8 @@ impl OlmMachine {
|
||||||
device_id: device_id.to_owned(),
|
device_id: device_id.to_owned(),
|
||||||
account: Arc::new(Mutex::new(Account::new())),
|
account: Arc::new(Mutex::new(Account::new())),
|
||||||
uploaded_signed_key_count: None,
|
uploaded_signed_key_count: None,
|
||||||
store: Box::new(MemoryStore::new()),
|
// store: Box::new(MemoryStore::new()),
|
||||||
|
sessions: SessionStore::new(),
|
||||||
inbound_group_sessions: GroupSessionStore::new(),
|
inbound_group_sessions: GroupSessionStore::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -120,7 +123,8 @@ impl OlmMachine {
|
||||||
device_id: device_id.to_owned(),
|
device_id: device_id.to_owned(),
|
||||||
account: Arc::new(Mutex::new(account)),
|
account: Arc::new(Mutex::new(account)),
|
||||||
uploaded_signed_key_count: None,
|
uploaded_signed_key_count: None,
|
||||||
store: Box::new(store),
|
// store: Box::new(store),
|
||||||
|
sessions: SessionStore::new(),
|
||||||
inbound_group_sessions: GroupSessionStore::new(),
|
inbound_group_sessions: GroupSessionStore::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -175,7 +179,7 @@ impl OlmMachine {
|
||||||
account.mark_keys_as_published();
|
account.mark_keys_as_published();
|
||||||
drop(account);
|
drop(account);
|
||||||
|
|
||||||
self.store.save_account(self.account.clone()).await?;
|
// self.store.save_account(self.account.clone()).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue