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