summary refs log tree commit diff
path: root/synapse/rest/media/v1/identicon_resource.py
diff options
context:
space:
mode:
authorKrombel <krombel@krombel.de>2018-07-13 21:40:14 +0200
committerKrombel <krombel@krombel.de>2018-07-13 21:40:14 +0200
commit32fd6910d0175f14d9be756ac2241da683af83bb (patch)
tree40ee591606c439c8309eb0aa25a01d1fef8f76d8 /synapse/rest/media/v1/identicon_resource.py
parentMerge pull request #3533 from matrix-org/rav/fix_federation_ratelimite_queue (diff)
downloadsynapse-32fd6910d0175f14d9be756ac2241da683af83bb.tar.xz
Use parse_{int,str} and assert from http.servlet
parse_integer and parse_string can take a request and raise errors
in case we have wrong or missing params.
This PR tries to use them more to deduplicate some code and make it
better readable
Diffstat (limited to 'synapse/rest/media/v1/identicon_resource.py')
-rw-r--r--synapse/rest/media/v1/identicon_resource.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/synapse/rest/media/v1/identicon_resource.py b/synapse/rest/media/v1/identicon_resource.py
index a2e391415f..b3217eff53 100644
--- a/synapse/rest/media/v1/identicon_resource.py
+++ b/synapse/rest/media/v1/identicon_resource.py
@@ -14,6 +14,8 @@
 
 from pydenticon import Generator
 
+from synapse.http.servlet import parse_integer
+
 from twisted.web.resource import Resource
 
 FOREGROUND = [
@@ -56,8 +58,8 @@ class IdenticonResource(Resource):
 
     def render_GET(self, request):
         name = "/".join(request.postpath)
-        width = int(request.args.get("width", [96])[0])
-        height = int(request.args.get("height", [96])[0])
+        width = parse_integer(request, "width", default=96)
+        height = parse_integer(request, "height", default=96)
         identicon_bytes = self.generate_identicon(name, width, height)
         request.setHeader(b"Content-Type", b"image/png")
         request.setHeader(