diff options
author | Erik Johnston <erikj@jki.re> | 2016-07-07 13:34:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-07 13:34:28 +0100 |
commit | 70d650be2b9c7a46ade43ef6ff3f6d07a7f36cc9 (patch) | |
tree | 9c46c887f687a01f44ccae03be3fea75c079ea85 /synapse/rest | |
parent | Merge pull request #909 from matrix-org/erikj/shared_secret (diff) | |
parent | Comment (diff) | |
download | synapse-70d650be2b9c7a46ade43ef6ff3f6d07a7f36cc9.tar.xz |
Merge pull request #911 from matrix-org/erikj/purge_history
Feature: Purge local room history.
Diffstat (limited to 'synapse/rest')
-rw-r--r-- | synapse/rest/client/v1/admin.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/synapse/rest/client/v1/admin.py b/synapse/rest/client/v1/admin.py index e54c472e08..b0cb31a448 100644 --- a/synapse/rest/client/v1/admin.py +++ b/synapse/rest/client/v1/admin.py @@ -77,6 +77,24 @@ class PurgeMediaCacheRestServlet(ClientV1RestServlet): defer.returnValue((200, ret)) +class PurgeHistoryRestServlet(ClientV1RestServlet): + PATTERNS = client_path_patterns( + "/admin/purge_history/(?P<room_id>[^/]*)/(?P<event_id>[^/]*)" + ) + + @defer.inlineCallbacks + def on_POST(self, request, room_id, event_id): + 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") + + yield self.handlers.message_handler.purge_history(room_id, event_id) + + defer.returnValue((200, {})) + + class DeactivateAccountRestServlet(ClientV1RestServlet): PATTERNS = client_path_patterns("/admin/deactivate/(?P<target_user_id>[^/]*)") @@ -106,3 +124,4 @@ def register_servlets(hs, http_server): WhoisRestServlet(hs).register(http_server) PurgeMediaCacheRestServlet(hs).register(http_server) DeactivateAccountRestServlet(hs).register(http_server) + PurgeHistoryRestServlet(hs).register(http_server) |