Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Remove users from user directory on deactivate #3277

Merged
merged 1 commit into from
May 24, 2018
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
4 changes: 4 additions & 0 deletions synapse/handlers/deactivate_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(self, hs):
self._auth_handler = hs.get_auth_handler()
self._device_handler = hs.get_device_handler()
self._room_member_handler = hs.get_room_member_handler()
self.user_directory_handler = hs.get_user_directory_handler()

# Flag that indicates whether the process to part users from rooms is running
self._user_parter_running = False
Expand Down Expand Up @@ -65,6 +66,9 @@ def deactivate_account(self, user_id):
# removal from all the rooms they're a member of)
yield self.store.add_user_pending_deactivation(user_id)

# delete from user directory
yield self.user_directory_handler.handle_user_deactivated(user_id)

# Now start the process that goes through that list and
# parts users from rooms (if it isn't already running)
self._start_user_parting()
Expand Down
7 changes: 7 additions & 0 deletions synapse/handlers/user_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ def handle_local_profile_change(self, user_id, profile):
user_id, profile.display_name, profile.avatar_url, None,
)

@defer.inlineCallbacks
def handle_user_deactivated(self, user_id):
"""Called when a user ID is deactivated
"""
yield self.store.remove_from_user_dir(user_id)
yield self.store.remove_from_user_in_public_room(user_id)

@defer.inlineCallbacks
def _unsafe_process(self):
# If self.pos is None then means we haven't fetched it from DB
Expand Down