This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add forgotten status to Room Details API #13503
Merged
erikjohnston
merged 9 commits into
matrix-org:develop
from
dklimpel:admin_api_forgotten
Aug 17, 2022
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6d4ef60
Add forgotten status to Room Details API
dklimpel 5071934
newsfile
dklimpel 2f9c6a2
code style
dklimpel f09613f
remove single whitespace
dklimpel 1a2e96d
uses `get_success`
dklimpel 8fa7eb8
change sql select to `count(*) > 0`
dklimpel 03efe4c
replace `inject_room_member` with `inject_member_event`
dklimpel 3ff3656
isort
dklimpel 7fc1185
Merge branch 'develop' into admin_api_forgotten
erikjohnston File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add forgotten status to Room Details API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1215,6 +1215,30 @@ def _get_forgotten_rooms_for_user_txn(txn: LoggingTransaction) -> Set[str]: | |
"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; | ||
""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The query plan looks sensible to me |
||
|
||
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. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should note that this was added in Synapse 1.66. I'll add something to this file now while preparing the release.