diff options
author | Erik Johnston <erik@matrix.org> | 2019-04-26 18:14:23 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-04-26 18:14:23 +0100 |
commit | d6118c5be61aed49f1aa3fac53a25a670bbbd245 (patch) | |
tree | 269071e6c6a87cc70a177f48f9546e97a5b0f1e2 /synapse/rest/client/v1/admin.py | |
parent | Newsfile (diff) | |
parent | Merge pull request #5103 from matrix-org/rav/fix_notif_loop (diff) | |
download | synapse-d6118c5be61aed49f1aa3fac53a25a670bbbd245.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/ratelimit_3pid_invite
Diffstat (limited to 'synapse/rest/client/v1/admin.py')
-rw-r--r-- | synapse/rest/client/v1/admin.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/synapse/rest/client/v1/admin.py b/synapse/rest/client/v1/admin.py index 7d7a75fc30..0a1e233b23 100644 --- a/synapse/rest/client/v1/admin.py +++ b/synapse/rest/client/v1/admin.py @@ -809,6 +809,44 @@ class DeleteGroupAdminRestServlet(ClientV1RestServlet): defer.returnValue((200, {})) +class AccountValidityRenewServlet(ClientV1RestServlet): + PATTERNS = client_path_patterns("/admin/account_validity/validity$") + + def __init__(self, hs): + """ + Args: + hs (synapse.server.HomeServer): server + """ + super(AccountValidityRenewServlet, self).__init__(hs) + + self.hs = hs + self.account_activity_handler = hs.get_account_validity_handler() + self.auth = hs.get_auth() + + @defer.inlineCallbacks + def on_POST(self, request): + requester = yield self.auth.get_user_by_req(request) + is_admin = yield self.auth.is_server_admin(requester.user) + + if not is_admin: + raise AuthError(403, "You are not a server admin") + + body = parse_json_object_from_request(request) + + if "user_id" not in body: + raise SynapseError(400, "Missing property 'user_id' in the request body") + + expiration_ts = yield 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, + } + defer.returnValue((200, res)) + + def register_servlets(hs, http_server): WhoisRestServlet(hs).register(http_server) PurgeMediaCacheRestServlet(hs).register(http_server) @@ -825,3 +863,4 @@ def register_servlets(hs, http_server): UserRegisterServlet(hs).register(http_server) VersionServlet(hs).register(http_server) DeleteGroupAdminRestServlet(hs).register(http_server) + AccountValidityRenewServlet(hs).register(http_server) |