diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2023-02-01 17:38:43 +0000 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2023-02-09 21:27:49 +0000 |
commit | 68a9ea3ec26e79317985e50ffa249e494cbe484d (patch) | |
tree | 5870ad390a3575b112064be1aca55a8099cb5b4b | |
parent | Poke Synapse modules when adding or removing a 3PID to a user's account (diff) | |
download | synapse-68a9ea3ec26e79317985e50ffa249e494cbe484d.tar.xz |
Refactor deactivate code to use AuthHandler's delete_threepid method
This deduplicates some code, as well as has the side-effect of ensuring Synapse modules are informed of a 3PID deletion even during user deactivation.
-rw-r--r-- | synapse/handlers/deactivate_account.py | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/synapse/handlers/deactivate_account.py b/synapse/handlers/deactivate_account.py index d74d135c0c..aea0f8b7c2 100644 --- a/synapse/handlers/deactivate_account.py +++ b/synapse/handlers/deactivate_account.py @@ -100,30 +100,20 @@ class DeactivateAccountHandler: # unbinding identity_server_supports_unbinding = True - # Retrieve the 3PIDs this user has bound to an identity server - threepids = await self.store.user_get_bound_threepids(user_id) - + # Remove any threepids associated with this account locally and attempt to + # unbind them from identity server(s). + threepids = await self.store.user_get_threepids(user_id) for threepid in threepids: try: - result = await self._identity_handler.try_unbind_threepid( - user_id, - { - "medium": threepid["medium"], - "address": threepid["address"], - "id_server": id_server, - }, + result = await self._auth_handler.delete_threepid( + user_id, threepid["medium"], threepid["address"], id_server ) - identity_server_supports_unbinding &= result except Exception: # Do we want this to be a fatal error or should we carry on? logger.exception("Failed to remove threepid from ID server") raise SynapseError(400, "Failed to remove threepid from ID server") - await self.store.user_delete_threepid( - user_id, threepid["medium"], threepid["address"] - ) - # Remove all 3PIDs this user has bound to the homeserver - await self.store.user_delete_threepids(user_id) + identity_server_supports_unbinding &= result # delete any devices belonging to the user, which will also # delete corresponding access tokens. |