Skip to content

Upon deactivation, forget all of the user's rooms #17400

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

Merged
merged 2 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/17400.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forget all of a user's rooms upon deactivation, enabling future purges.
4 changes: 4 additions & 0 deletions synapse/handlers/deactivate_account.py
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't apply to all historically deactivated users, but it may be possible to do that with a database migration or manually? Not sure it's a feature we want/need.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fairly easy to add a background update to do this if we want. It'd just be pulling out deactivated users and then forgetting all their rooms. I don't really mind if we do it or not though

Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ async def _part_user(self, user_id: str) -> None:
ratelimit=False,
require_consent=False,
)

# Mark the room forgotten too, because they won't be able to do this
# for us. This may lead to the room being purged eventually.
await self._room_member_handler.forget(user, room_id)
except Exception:
logger.exception(
"Failed to part user %r from room %r: ignoring and continuing",
Expand Down
22 changes: 22 additions & 0 deletions tests/handlers/test_deactivate_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,25 @@ def test_membership_is_redacted_upon_deactivation(self) -> None:
# Validate that there is no displayname in any of the events
for event in events:
self.assertTrue("displayname" not in event.content)

def test_rooms_forgotten_upon_deactivation(self) -> None:
"""
Tests that the user 'forgets' the rooms they left upon deactivation.
"""
# Create a room
room_id = self.helper.create_room_as(
self.user,
is_public=True,
tok=self.token,
)

# Deactivate the account
self._deactivate_my_account()

# Get all of the user's forgotten rooms
forgotten_rooms = self.get_success(
self._store.get_forgotten_rooms_for_user(self.user)
)

# Validate that the created room is forgotten
self.assertTrue(room_id in forgotten_rooms)
Loading