diff options
author | David Baker <dave@matrix.org> | 2018-05-08 15:58:35 +0100 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2018-05-08 15:58:35 +0100 |
commit | bf98fa0864fe62dbf1303acc778912d69fd4a738 (patch) | |
tree | df8cb644376f68d154b46b07f54953a3716072a0 /synapse | |
parent | Merge pull request #3190 from mujx/notif-token-fix (diff) | |
download | synapse-bf98fa0864fe62dbf1303acc778912d69fd4a738.tar.xz |
Part user from rooms on account deactivate
This implements this very crudely: this probably isn't viable because parting a user from all their rooms could take a long time, and if the HS gets restarted in that time the process will be aborted.
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/handlers/deactivate_account.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/synapse/handlers/deactivate_account.py b/synapse/handlers/deactivate_account.py index b1d3814909..387620c9c6 100644 --- a/synapse/handlers/deactivate_account.py +++ b/synapse/handlers/deactivate_account.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2017 New Vector Ltd +# Copyright 2017, 2018 New Vector Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ from twisted.internet import defer from ._base import BaseHandler +from synapse.types import UserID, create_requester import logging @@ -27,6 +28,7 @@ class DeactivateAccountHandler(BaseHandler): super(DeactivateAccountHandler, self).__init__(hs) self._auth_handler = hs.get_auth_handler() self._device_handler = hs.get_device_handler() + self._room_member_handler = hs.get_room_member_handler() @defer.inlineCallbacks def deactivate_account(self, user_id): @@ -50,3 +52,15 @@ class DeactivateAccountHandler(BaseHandler): yield self.store.user_delete_threepids(user_id) yield self.store.user_set_password_hash(user_id, None) + + user = UserID.from_string(user_id) + + rooms_for_user = yield self.store.get_rooms_for_user(user_id) + for room_id in rooms_for_user: + yield self._room_member_handler.update_membership( + create_requester(user), + user, + room_id, + "leave", + ratelimit=False, + ) |