diff --git a/synapse/handlers/deactivate_account.py b/synapse/handlers/deactivate_account.py index 7e31abf0e8..34596ade16 100644 --- a/synapse/handlers/deactivate_account.py +++ b/synapse/handlers/deactivate_account.py @@ -172,8 +172,10 @@ class DeactivateAccountHandler: # Note that displayname and avatar URL may persist as historical state events # in rooms, but these cases behave like message history, following # https://spec.matrix.org/v1.17/client-server-api/#post_matrixclientv3accountdeactivate - await self._profile_handler.dispatch_delete_profile_upon_deactivation( - user, requester, by_admin + await self._profile_handler.delete_profile_upon_deactivation( + target_user=user, + requester=requester, + by_admin=by_admin, ) logger.info("Marking %s as erased", user_id) diff --git a/synapse/handlers/profile.py b/synapse/handlers/profile.py index fc85372ec4..5f2cec2366 100644 --- a/synapse/handlers/profile.py +++ b/synapse/handlers/profile.py @@ -36,7 +36,6 @@ from synapse.api.errors import ( ) from synapse.replication.http.profile import ( ReplicationProfileDeleteField, - ReplicationProfileDeleteUponDeactivation, ReplicationProfileSetField, ) from synapse.storage.databases.main.media_repository import LocalMedia, RemoteMedia @@ -114,9 +113,6 @@ class ProfileHandler: self._delete_profile_field_client = ReplicationProfileDeleteField.make_client( self.hs ) - self._delete_profile_upon_deactivation_client = ( - ReplicationProfileDeleteUponDeactivation.make_client(self.hs) - ) self._set_profile_field_client = ReplicationProfileSetField.make_client(self.hs) self._profile_updates_writer_instance = self.hs.config.worker.writers.events[0] @@ -419,37 +415,6 @@ class ProfileHandler: return stream_id - async def dispatch_delete_profile_upon_deactivation( - self, - target_user: UserID, - requester: Requester, - by_admin: bool = False, - ) -> None: - """ - Dispatch profile deletion upon deactivation to the right instance that - can write to the profile updates stream, or handle it ourselves, - if we're an events stream writer. - - Args: - target_user: User ID whose profile is being deactivated. - requester: The requesting user. - by_admin: Whether the action is being done by an admin. - """ - if self._is_events_writer: - await self.delete_profile_upon_deactivation( - target_user=target_user, - requester=requester, - by_admin=by_admin, - ) - else: - # Offload to the right worker via http replication - await self._delete_profile_upon_deactivation_client( - instance_name=self._profile_updates_writer_instance, - user_id=target_user.to_string(), - requester=requester, - by_admin=by_admin, - ) - async def delete_profile_upon_deactivation( self, target_user: UserID, diff --git a/synapse/replication/http/profile.py b/synapse/replication/http/profile.py index cc7164b382..60e3175f53 100644 --- a/synapse/replication/http/profile.py +++ b/synapse/replication/http/profile.py @@ -149,59 +149,6 @@ class ReplicationProfileDeleteField(ReplicationEndpoint): return (200, {}) -class ReplicationProfileDeleteUponDeactivation(ReplicationEndpoint): - """Delete a profile for a user during deactivation. - - The POST looks like: - - POST /_synapse/replication/profile_delete_upon_deactivation/ - - { - "target_user": "@user:hs", - "requester": "@admin:hs", - "by_admin": true - } - - 200 OK - - {} - """ - - NAME = "profile_delete_upon_deactivation" - PATH_ARGS = ("user_id",) - METHOD = "POST" - CACHE = False - - def __init__(self, hs: "HomeServer"): - super().__init__(hs) - - self._profile_handler = hs.get_profile_handler() - - @staticmethod - async def _serialize_payload( # type: ignore[override] - user_id: str, - requester: Requester, - by_admin: bool, - ) -> JsonDict: - return { - "target_user": user_id, - "requester": requester.user.to_string(), - "by_admin": by_admin, - } - - async def _handle_request( # type: ignore[override] - self, request: Request, content: JsonDict, user_id: str - ) -> tuple[int, JsonDict]: - await self._profile_handler.delete_profile_upon_deactivation( - target_user=UserID.from_string(user_id), - requester=create_requester(content["requester"]), - by_admin=content["by_admin"], - ) - - return (200, {}) - - def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None: ReplicationProfileSetField(hs).register(http_server) ReplicationProfileDeleteField(hs).register(http_server) - ReplicationProfileDeleteUponDeactivation(hs).register(http_server)