mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 08:56:04 -04:00
Add forgotten status to Room Details API (#13503)
This commit is contained in:
parent
c6ee9c0ee4
commit
d75512d19e
6 changed files with 101 additions and 1 deletions
|
@ -1215,6 +1215,30 @@ class RoomMemberWorkerStore(EventsWorkerStore):
|
|||
"get_forgotten_rooms_for_user", _get_forgotten_rooms_for_user_txn
|
||||
)
|
||||
|
||||
async def is_locally_forgotten_room(self, room_id: str) -> bool:
|
||||
"""Returns whether all local users have forgotten this room_id.
|
||||
|
||||
Args:
|
||||
room_id: The room ID to query.
|
||||
|
||||
Returns:
|
||||
Whether the room is forgotten.
|
||||
"""
|
||||
|
||||
sql = """
|
||||
SELECT count(*) > 0 FROM local_current_membership
|
||||
INNER JOIN room_memberships USING (room_id, event_id)
|
||||
WHERE
|
||||
room_id = ?
|
||||
AND forgotten = 0;
|
||||
"""
|
||||
|
||||
rows = await self.db_pool.execute("is_forgotten_room", None, sql, room_id)
|
||||
|
||||
# `count(*)` returns always an integer
|
||||
# If any rows still exist it means someone has not forgotten this room yet
|
||||
return not rows[0][0]
|
||||
|
||||
async def get_rooms_user_has_been_in(self, user_id: str) -> Set[str]:
|
||||
"""Get all rooms that the user has ever been in.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue