-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sliding sync: Ignore invites from ignored users #17729
Merged
MadLittleMods
merged 6 commits into
develop
from
madlittlemods/ignore-invites-from-ignored-users
Sep 18, 2024
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
eb5056c
Ingore invites from ignored users
MadLittleMods 227bee1
Better comments
MadLittleMods a48c1b5
Add changelog
MadLittleMods 54476d8
Only copy when we need to mutate
MadLittleMods 269759b
Make sure ignored invites do not show up in incremental syncs
MadLittleMods d909c39
Update comment
MadLittleMods 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 @@ | ||
Ignore invites from ignored users in Sliding Sync. |
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 |
---|---|---|
|
@@ -224,15 +224,31 @@ async def _compute_interested_rooms_new_tables( | |
user_id | ||
) | ||
|
||
# Remove invites from ignored users | ||
ignored_users = await self.store.ignored_users(user_id) | ||
if ignored_users: | ||
# TODO: It would be nice to avoid these copies | ||
room_membership_for_user_map = dict(room_membership_for_user_map) | ||
# Make a copy so we don't run into an error: `dictionary changed size during | ||
# iteration`, when we remove items | ||
for room_id in list(room_membership_for_user_map.keys()): | ||
room_for_user_sliding_sync = room_membership_for_user_map[room_id] | ||
if ( | ||
room_for_user_sliding_sync.membership == Membership.INVITE | ||
and room_for_user_sliding_sync.sender in ignored_users | ||
): | ||
room_membership_for_user_map.pop(room_id, None) | ||
|
||
changes = await self._get_rewind_changes_to_current_membership_to_token( | ||
sync_config.user, room_membership_for_user_map, to_token=to_token | ||
) | ||
if changes: | ||
# TODO: It would be nice to avoid these copies | ||
room_membership_for_user_map = dict(room_membership_for_user_map) | ||
for room_id, change in changes.items(): | ||
if change is None: | ||
# Remove rooms that the user joined after the `to_token` | ||
room_membership_for_user_map.pop(room_id) | ||
room_membership_for_user_map.pop(room_id, None) | ||
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. Unrelated but added a default to the |
||
continue | ||
|
||
existing_room = room_membership_for_user_map.get(room_id) | ||
|
@@ -926,6 +942,18 @@ async def get_room_membership_for_user_at_to_token( | |
excluded_rooms=self.rooms_to_exclude_globally, | ||
) | ||
|
||
# Remove invites from ignored users | ||
ignored_users = await self.store.ignored_users(user_id) | ||
if ignored_users: | ||
room_for_user_list = [ | ||
room_for_user | ||
for room_for_user in room_for_user_list | ||
if not ( | ||
room_for_user.membership == Membership.INVITE | ||
and room_for_user.sender in ignored_users | ||
) | ||
] | ||
|
||
# If the user has never joined any rooms before, we can just return an empty list | ||
if not room_for_user_list: | ||
return {}, set(), set() | ||
|
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
Oops, something went wrong.
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.
Another reason to potentially add
SoftDeleteChainMap
(context #17725 (comment))Would tackle in a separate PR though.