From d0e17ae274054734648a5a4b112e23fdb4b612a1 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Wed, 14 Jan 2026 16:59:05 +0000 Subject: [PATCH] Add the ability to deactivate users in the MAS client As we won't be able to deactivate them using the Synapse module API --- .../synapse/synapse_guest_module/mas_admin_client.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/restricted-guests/synapse/synapse_guest_module/mas_admin_client.py b/modules/restricted-guests/synapse/synapse_guest_module/mas_admin_client.py index 286a2e2f12..299481da68 100644 --- a/modules/restricted-guests/synapse/synapse_guest_module/mas_admin_client.py +++ b/modules/restricted-guests/synapse/synapse_guest_module/mas_admin_client.py @@ -78,6 +78,17 @@ class MasAdminClient: return device_id, access_token + async def deactivate_user(self, mas_user_id: str, token: str | None = None) -> None: + if token is None: + token = await self.request_admin_token() + + url = self._build_admin_url(f"/api/admin/v1/users/{mas_user_id}/deactivate") + await self._api.http_client.post_json_get_json( + uri=url, + post_json={"skip_erase": True}, + headers={"Authorization": [f"Bearer {token}"]}, + ) + async def request_admin_token(self) -> str: url = self._build_oauth_url("/oauth2/token") basic_auth = base64.b64encode(