diff options
author | Amber Brown <hawkowl@atleastfornow.net> | 2018-07-14 09:09:19 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-14 09:09:19 +1000 |
commit | 8532953c048ba8dc258d57d18e56e2243c41b085 (patch) | |
tree | 1de20a1972e313b196b2c5abcacb5d40413a8b36 /synapse/rest/client/v1/pusher.py | |
parent | Make auth & transactions more testable (#3499) (diff) | |
parent | fix sytests (diff) | |
download | synapse-8532953c048ba8dc258d57d18e56e2243c41b085.tar.xz |
Merge pull request #3534 from krombel/use_parse_and_asserts_from_servlet
Use parse and asserts from http.servlet
Diffstat (limited to 'synapse/rest/client/v1/pusher.py')
-rw-r--r-- | synapse/rest/client/v1/pusher.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/synapse/rest/client/v1/pusher.py b/synapse/rest/client/v1/pusher.py index 1581f88db5..182a68b1e2 100644 --- a/synapse/rest/client/v1/pusher.py +++ b/synapse/rest/client/v1/pusher.py @@ -21,6 +21,7 @@ from synapse.api.errors import Codes, StoreError, SynapseError from synapse.http.server import finish_request from synapse.http.servlet import ( RestServlet, + assert_params_in_dict, parse_json_object_from_request, parse_string, ) @@ -91,15 +92,11 @@ class PushersSetRestServlet(ClientV1RestServlet): ) defer.returnValue((200, {})) - reqd = ['kind', 'app_id', 'app_display_name', - 'device_display_name', 'pushkey', 'lang', 'data'] - missing = [] - for i in reqd: - if i not in content: - missing.append(i) - if len(missing): - raise SynapseError(400, "Missing parameters: " + ','.join(missing), - errcode=Codes.MISSING_PARAM) + assert_params_in_dict( + content, + ['kind', 'app_id', 'app_display_name', + 'device_display_name', 'pushkey', 'lang', 'data'] + ) logger.debug("set pushkey %s to kind %s", content['pushkey'], content['kind']) logger.debug("Got pushers request with body: %r", content) @@ -148,7 +145,7 @@ class PushersRemoveRestServlet(RestServlet): SUCCESS_HTML = "<html><body>You have been unsubscribed</body><html>" def __init__(self, hs): - super(RestServlet, self).__init__() + super(PushersRemoveRestServlet, self).__init__() self.hs = hs self.notifier = hs.get_notifier() self.auth = hs.get_auth() |