Purge room synctokens during deletion.
Purge last notification read counts. Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -157,8 +157,24 @@ impl Service {
|
|||||||
.log_err()
|
.log_err()
|
||||||
.ok();
|
.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!("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");
|
debug!("Deleting room state hash from our database");
|
||||||
self.services
|
self.services
|
||||||
.state
|
.state
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use ruma::{RoomId, UserId};
|
use ruma::{RoomId, UserId};
|
||||||
use tuwunel_core::{Result, implement};
|
use tuwunel_core::{
|
||||||
use tuwunel_database::{Database, Deserialized, Map};
|
Result, implement, trace,
|
||||||
|
utils::stream::{ReadyExt, TryIgnore},
|
||||||
|
};
|
||||||
|
use tuwunel_database::{Database, Deserialized, Interfix, Map};
|
||||||
|
|
||||||
use crate::rooms::short::ShortStateHash;
|
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)
|
.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)]
|
#[implement(Service)]
|
||||||
#[tracing::instrument(level = "trace", skip(self))]
|
#[tracing::instrument(level = "trace", skip(self))]
|
||||||
pub async fn associate_token_shortstatehash(
|
pub async fn associate_token_shortstatehash(
|
||||||
@@ -128,3 +149,24 @@ pub async fn get_token_shortstatehash(
|
|||||||
.await
|
.await
|
||||||
.deserialized()
|
.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(())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user