Purge room synctokens during deletion.
Purge last notification read counts. Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
1322ba1b00
commit
10fb1cd192
2 changed files with 60 additions and 2 deletions
|
|
@ -157,8 +157,24 @@ impl Service {
|
|||
.log_err()
|
||||
.ok();
|
||||
|
||||
debug!("Deleting the room's last notifications read.");
|
||||
self.services
|
||||
.user
|
||||
.delete_room_notification_read(room_id)
|
||||
.await
|
||||
.log_err()
|
||||
.ok();
|
||||
|
||||
debug!("Final stages of deleting the room");
|
||||
|
||||
debug!("Deleting room sync tokens from our database");
|
||||
self.services
|
||||
.user
|
||||
.delete_room_synctokens(room_id)
|
||||
.await
|
||||
.log_err()
|
||||
.ok();
|
||||
|
||||
debug!("Deleting room state hash from our database");
|
||||
self.services
|
||||
.state
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use ruma::{RoomId, UserId};
|
||||
use tuwunel_core::{Result, implement};
|
||||
use tuwunel_database::{Database, Deserialized, Map};
|
||||
use tuwunel_core::{
|
||||
Result, implement, trace,
|
||||
utils::stream::{ReadyExt, TryIgnore},
|
||||
};
|
||||
use tuwunel_database::{Database, Deserialized, Interfix, Map};
|
||||
|
||||
use crate::rooms::short::ShortStateHash;
|
||||
|
||||
|
|
@ -87,6 +90,24 @@ pub async fn last_notification_read(&self, user_id: &UserId, room_id: &RoomId) -
|
|||
.unwrap_or(0)
|
||||
}
|
||||
|
||||
#[implement(Service)]
|
||||
pub async fn delete_room_notification_read(&self, room_id: &RoomId) -> Result {
|
||||
let key = (room_id, Interfix);
|
||||
self.db
|
||||
.roomuserid_lastnotificationread
|
||||
.keys_prefix_raw(&key)
|
||||
.ignore_err()
|
||||
.ready_for_each(|key| {
|
||||
trace!("Removing key: {key:?}");
|
||||
self.db
|
||||
.roomuserid_lastnotificationread
|
||||
.remove(key);
|
||||
})
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[implement(Service)]
|
||||
#[tracing::instrument(level = "trace", skip(self))]
|
||||
pub async fn associate_token_shortstatehash(
|
||||
|
|
@ -128,3 +149,24 @@ pub async fn get_token_shortstatehash(
|
|||
.await
|
||||
.deserialized()
|
||||
}
|
||||
|
||||
#[implement(Service)]
|
||||
pub async fn delete_room_synctokens(&self, room_id: &RoomId) -> Result {
|
||||
let shortroomid = self
|
||||
.services
|
||||
.short
|
||||
.get_shortroomid(room_id)
|
||||
.await?;
|
||||
|
||||
self.db
|
||||
.roomsynctoken_shortstatehash
|
||||
.keys_prefix_raw(&shortroomid)
|
||||
.ignore_err()
|
||||
.ready_for_each(|key| {
|
||||
trace!("Removing key: {key:?}");
|
||||
self.db.roomsynctoken_shortstatehash.remove(key);
|
||||
})
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue