summary refs log tree commit diff
path: root/synapse/rest/admin
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2021-07-16 18:11:53 +0200
committerGitHub <noreply@github.com>2021-07-16 18:11:53 +0200
commit36dc15412de9fc1bb2ba955c8b6f2da20d2ca20f (patch)
treec0e97c91cdd0270370fd5fbe7a5a085a996fd3aa /synapse/rest/admin
parentDo not include signatures/hashes in make_{join,leave,knock} responses. (#10404) (diff)
downloadsynapse-36dc15412de9fc1bb2ba955c8b6f2da20d2ca20f.tar.xz
Add a module type for account validity (#9884)
This adds an API for third-party plugin modules to implement account validity, so they can provide this feature instead of Synapse. The module implementing the current behaviour for this feature can be found at https://github.com/matrix-org/synapse-email-account-validity.

To allow for a smooth transition between the current feature and the new module, hooks have been added to the existing account validity endpoints to allow their behaviours to be overridden by a module.
Diffstat (limited to 'synapse/rest/admin')
-rw-r--r--synapse/rest/admin/users.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/synapse/rest/admin/users.py b/synapse/rest/admin/users.py
index 7d75564758..06e6ccee42 100644
--- a/synapse/rest/admin/users.py
+++ b/synapse/rest/admin/users.py
@@ -560,16 +560,24 @@ class AccountValidityRenewServlet(RestServlet):
     async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
         await assert_requester_is_admin(self.auth, request)
 
-        body = parse_json_object_from_request(request)
+        if self.account_activity_handler.on_legacy_admin_request_callback:
+            expiration_ts = await (
+                self.account_activity_handler.on_legacy_admin_request_callback(request)
+            )
+        else:
+            body = parse_json_object_from_request(request)
 
-        if "user_id" not in body:
-            raise SynapseError(400, "Missing property 'user_id' in the request body")
+            if "user_id" not in body:
+                raise SynapseError(
+                    400,
+                    "Missing property 'user_id' in the request body",
+                )
 
-        expiration_ts = await self.account_activity_handler.renew_account_for_user(
-            body["user_id"],
-            body.get("expiration_ts"),
-            not body.get("enable_renewal_emails", True),
-        )
+            expiration_ts = await self.account_activity_handler.renew_account_for_user(
+                body["user_id"],
+                body.get("expiration_ts"),
+                not body.get("enable_renewal_emails", True),
+            )
 
         res = {"expiration_ts": expiration_ts}
         return 200, res