crypto: Store that our outbound session was invalidated
parent
ebcb2024d1
commit
cb58c499b3
|
@ -310,7 +310,7 @@ impl Joined {
|
|||
self.client
|
||||
.base_client
|
||||
.invalidate_group_session(self.inner.room_id())
|
||||
.await;
|
||||
.await?;
|
||||
return Err(r);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1184,12 +1184,15 @@ impl BaseClient {
|
|||
/// to invalidate.
|
||||
#[cfg(feature = "encryption")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(encryption)))]
|
||||
pub async fn invalidate_group_session(&self, room_id: &RoomId) -> bool {
|
||||
pub async fn invalidate_group_session(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
) -> Result<bool, CryptoStoreError> {
|
||||
let olm = self.olm.lock().await;
|
||||
|
||||
match &*olm {
|
||||
Some(o) => o.invalidate_group_session(room_id),
|
||||
None => false,
|
||||
Some(o) => o.invalidate_group_session(room_id).await,
|
||||
None => Ok(false),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -672,8 +672,10 @@ impl OlmMachine {
|
|||
///
|
||||
/// Returns true if a session was invalidated, false if there was no session
|
||||
/// to invalidate.
|
||||
pub fn invalidate_group_session(&self, room_id: &RoomId) -> bool {
|
||||
self.group_session_manager.invalidate_group_session(room_id)
|
||||
pub async fn invalidate_group_session(&self, room_id: &RoomId) -> StoreResult<bool> {
|
||||
self.group_session_manager
|
||||
.invalidate_group_session(room_id)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Get to-device requests to share a group session with users in a room.
|
||||
|
|
|
@ -66,12 +66,17 @@ impl GroupSessionManager {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn invalidate_group_session(&self, room_id: &RoomId) -> bool {
|
||||
pub async fn invalidate_group_session(&self, room_id: &RoomId) -> StoreResult<bool> {
|
||||
if let Some(s) = self.outbound_group_sessions.get(room_id) {
|
||||
s.invalidate_session();
|
||||
true
|
||||
|
||||
let mut changes = Changes::default();
|
||||
changes.outbound_group_sessions.push(s.clone());
|
||||
self.store.save_changes(changes).await?;
|
||||
|
||||
Ok(true)
|
||||
} else {
|
||||
false
|
||||
Ok(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue