Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Only handle GET requests for /push_rules
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Apr 15, 2019
1 parent 2082519 commit ec638a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/workers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ following regular expressions::
^/_matrix/client/(api/v1|r0|unstable)/keys/changes$
^/_matrix/client/versions$
^/_matrix/client/(api/v1|r0|unstable)/voip/turnServer$

Additionally, the following REST endpoints can be handled for GET requests::

^/_matrix/client/(api/v1|r0|unstable)/pushrules/.*$

Additionally, the following REST endpoints can be handled, but all requests must
Expand Down
7 changes: 7 additions & 0 deletions synapse/rest/client/v1/push_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ def __init__(self, hs):
super(PushRuleRestServlet, self).__init__(hs)
self.store = hs.get_datastore()
self.notifier = hs.get_notifier()
self._is_worker = hs.config.worker_app is not None

@defer.inlineCallbacks
def on_PUT(self, request):
if self._is_worker:
raise Exception("Cannot handle PUT /push_rules on worker")

spec = _rule_spec_from_path([x.decode('utf8') for x in request.postpath])
try:
priority_class = _priority_class_from_spec(spec)
Expand Down Expand Up @@ -103,6 +107,9 @@ def on_PUT(self, request):

@defer.inlineCallbacks
def on_DELETE(self, request):
if self._is_worker:
raise Exception("Cannot handle DELETE /push_rules on worker")

spec = _rule_spec_from_path([x.decode('utf8') for x in request.postpath])

requester = yield self.auth.get_user_by_req(request)
Expand Down

0 comments on commit ec638a1

Please sign in to comment.