unfinished untested impl of room deletion

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-02-20 22:40:46 -05:00
parent 0593dce8a6
commit a94bf2cf9f
31 changed files with 400 additions and 9 deletions

View file

@ -29,4 +29,6 @@ pub trait Data: Send + Sync {
/// Returns the count of the last typing update in this room.
fn last_privateread_update(&self, user_id: &UserId, room_id: &RoomId) -> Result<u64>;
fn delete_all_private_read_receipts(&self, room_id: &RoomId) -> Result<()>;
}

View file

@ -52,4 +52,8 @@ impl Service {
pub fn last_privateread_update(&self, user_id: &UserId, room_id: &RoomId) -> Result<u64> {
self.db.last_privateread_update(user_id, room_id)
}
pub fn delete_all_private_read_receipts(&self, room_id: &RoomId) -> Result<()> {
self.db.delete_all_private_read_receipts(room_id)
}
}

View file

@ -16,6 +16,8 @@ pub trait Data: Send + Sync {
/// Returns the count of the last typing update in this room.
fn last_typing_update(&self, room_id: &RoomId) -> Result<u64>;
fn delete_all_typing_updates(&self, room_id: &RoomId) -> Result<()>;
/// Returns all user ids currently typing.
fn typings_all(&self, room_id: &RoomId) -> Result<HashSet<OwnedUserId>>;
}

View file

@ -33,6 +33,10 @@ impl Service {
self.db.last_typing_update(room_id)
}
pub fn delete_all_typing_updates(&self, room_id: &RoomId) -> Result<()> {
self.db.delete_all_typing_updates(room_id)
}
/// Returns a new typing EDU.
pub fn typings_all(
&self,

View file

@ -16,6 +16,7 @@ pub trait Data: Send + Sync {
until: PduCount,
) -> PduData<'a>;
fn mark_as_referenced(&self, room_id: &RoomId, event_ids: &[Arc<EventId>]) -> Result<()>;
fn delete_all_referenced_for_room(&self, room_id: &RoomId) -> Result<()>;
fn is_event_referenced(&self, room_id: &RoomId, event_id: &EventId) -> Result<bool>;
fn mark_event_soft_failed(&self, event_id: &EventId) -> Result<()>;
fn is_event_soft_failed(&self, event_id: &EventId) -> Result<bool>;

View file

@ -173,6 +173,10 @@ impl Service {
self.db.mark_as_referenced(room_id, event_ids)
}
pub fn delete_all_referenced_for_room(&self, room_id: &RoomId) -> Result<()> {
self.db.delete_all_referenced_for_room(room_id)
}
#[tracing::instrument(skip(self))]
pub fn is_event_referenced(&self, room_id: &RoomId, event_id: &EventId) -> Result<bool> {
self.db.is_event_referenced(room_id, event_id)

View file

@ -7,4 +7,6 @@ pub trait Data: Send + Sync {
fn index_pdu(&self, shortroomid: u64, pdu_id: &[u8], message_body: &str) -> Result<()>;
fn search_pdus<'a>(&'a self, room_id: &RoomId, search_string: &str) -> SearchPdusResult<'a>;
fn delete_all_search_tokenids_for_room(&self, room_id: &RoomId) -> Result<()>;
}

View file

@ -23,4 +23,8 @@ impl Service {
) -> Result<Option<(impl Iterator<Item = Vec<u8>> + 'a, Vec<String>)>> {
self.db.search_pdus(room_id, search_string)
}
pub fn delete_all_search_tokenids_for_room(&self, room_id: &RoomId) -> Result<()> {
self.db.delete_all_search_tokenids_for_room(room_id)
}
}

View file

@ -28,4 +28,6 @@ pub trait Data: Send + Sync {
fn get_shortroomid(&self, room_id: &RoomId) -> Result<Option<u64>>;
fn get_or_create_shortroomid(&self, room_id: &RoomId) -> Result<u64>;
fn delete_shortroomid(&self, room_id: &RoomId) -> Result<()>;
}

View file

@ -51,4 +51,8 @@ impl Service {
pub fn get_or_create_shortroomid(&self, room_id: &RoomId) -> Result<u64> {
self.db.get_or_create_shortroomid(room_id)
}
pub fn delete_shortroomid(&self, room_id: &RoomId) -> Result<()> {
self.db.delete_shortroomid(room_id)
}
}

View file

@ -15,6 +15,12 @@ pub trait Data: Send + Sync {
_mutex_lock: &MutexGuard<'_, ()>, // Take mutex guard to make sure users get the room state mutex
) -> Result<()>;
fn delete_room_shortstatehash(
&self,
room_id: &RoomId,
_mutex_lock: &MutexGuard<'_, ()>,
) -> Result<()>;
/// Associates a state with an event.
fn set_event_state(&self, shorteventid: u64, shortstatehash: u64) -> Result<()>;
@ -28,4 +34,6 @@ pub trait Data: Send + Sync {
event_ids: Vec<OwnedEventId>,
_mutex_lock: &MutexGuard<'_, ()>, // Take mutex guard to make sure users get the room state mutex
) -> Result<()>;
fn delete_all_rooms_forward_extremities(&self, room_id: &RoomId) -> Result<()>;
}

View file

@ -321,6 +321,14 @@ impl Service {
self.db.set_room_state(room_id, shortstatehash, mutex_lock)
}
pub fn delete_room_shortstatehash(
&self,
room_id: &RoomId,
mutex_lock: &MutexGuard<'_, ()>,
) -> Result<()> {
self.db.delete_room_shortstatehash(room_id, mutex_lock)
}
/// Returns the room's version.
#[tracing::instrument(skip(self))]
pub fn get_room_version(&self, room_id: &RoomId) -> Result<RoomVersionId> {
@ -362,6 +370,10 @@ impl Service {
.set_forward_extremities(room_id, event_ids, state_lock)
}
pub fn delete_all_rooms_forward_extremities(&self, room_id: &RoomId) -> Result<()> {
self.db.delete_all_rooms_forward_extremities(room_id)
}
/// This fetches auth events from the current state.
#[tracing::instrument(skip(self))]
pub fn get_auth_events(

View file

@ -27,6 +27,8 @@ pub trait Data: Send + Sync {
fn update_joined_count(&self, room_id: &RoomId) -> Result<()>;
fn delete_room_join_counts(&self, room_id: &RoomId) -> Result<()>;
fn get_our_real_users(&self, room_id: &RoomId) -> Result<Arc<HashSet<OwnedUserId>>>;
fn appservice_in_room(

View file

@ -232,6 +232,10 @@ impl Service {
self.db.update_joined_count(room_id)
}
pub fn delete_room_join_counts(&self, room_id: &RoomId) -> Result<()> {
self.db.delete_room_join_counts(room_id)
}
#[tracing::instrument(skip(self, room_id))]
pub fn get_our_real_users(&self, room_id: &RoomId) -> Result<Arc<HashSet<OwnedUserId>>> {
self.db.get_our_real_users(room_id)

View file

@ -13,5 +13,8 @@ pub trait Data: Send + Sync {
) -> PduEventIterResult<'a>;
fn update_participants(&self, root_id: &[u8], participants: &[OwnedUserId]) -> Result<()>;
fn get_participants(&self, root_id: &[u8]) -> Result<Option<Vec<OwnedUserId>>>;
fn delete_all_rooms_threads(&self, room_id: &RoomId) -> Result<()>;
}

View file

@ -26,6 +26,10 @@ impl Service {
self.db.threads_until(user_id, room_id, until, include)
}
pub fn delete_all_rooms_threads(&self, room_id: &RoomId) -> Result<()> {
self.db.delete_all_rooms_threads(room_id)
}
pub fn add_to_thread(&self, root_event_id: &EventId, pdu: &PduEvent) -> Result<()> {
let root_id = &services()
.rooms

View file

@ -81,4 +81,6 @@ pub trait Data: Send + Sync {
notifies: Vec<OwnedUserId>,
highlights: Vec<OwnedUserId>,
) -> Result<()>;
fn delete_all_pdus_for_room(&self, room_id: &RoomId) -> Result<()>;
}

View file

@ -100,6 +100,10 @@ pub struct Service {
}
impl Service {
pub fn delete_all_pdus_for_room(&self, room_id: &RoomId) -> Result<()> {
self.db.delete_all_pdus_for_room(room_id)
}
#[tracing::instrument(skip(self))]
pub fn first_pdu_in_room(&self, room_id: &RoomId) -> Result<Option<Arc<PduEvent>>> {
self.all_pdus(user_id!("@doesntmatter:conduit.rs"), room_id)?