summary refs log tree commit diff
path: root/synapse/rest/media/v1
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-01-16 16:17:38 +0000
committerErik Johnston <erik@matrix.org>2018-01-16 16:17:38 +0000
commit6368e5c0ab39e43ee6950ba94a826c44db7d43f7 (patch)
tree418a26e2d894161a9753380fd7ddf0bbd7ec87f2 /synapse/rest/media/v1
parentMove setting of file_id up to caller (diff)
downloadsynapse-6368e5c0ab39e43ee6950ba94a826c44db7d43f7.tar.xz
Change _generate_thumbnails to take media_type
Diffstat (limited to 'synapse/rest/media/v1')
-rw-r--r--synapse/rest/media/v1/media_repository.py11
-rw-r--r--synapse/rest/media/v1/preview_url_resource.py6
2 files changed, 10 insertions, 7 deletions
diff --git a/synapse/rest/media/v1/media_repository.py b/synapse/rest/media/v1/media_repository.py
index 35c1dcbc97..e08cf8af46 100644
--- a/synapse/rest/media/v1/media_repository.py
+++ b/synapse/rest/media/v1/media_repository.py
@@ -151,7 +151,9 @@ class MediaRepository(object):
             "media_length": content_length,
         }
 
-        yield self._generate_thumbnails(None, media_id, media_id, media_info)
+        yield self._generate_thumbnails(
+            None, media_id, media_id, media_info["media_type"],
+        )
 
         defer.returnValue("mxc://%s/%s" % (self.server_name, media_id))
 
@@ -413,7 +415,7 @@ class MediaRepository(object):
         }
 
         yield self._generate_thumbnails(
-            server_name, media_id, file_id, media_info,
+            server_name, media_id, file_id, media_info["media_type"],
         )
 
         defer.returnValue(media_info)
@@ -525,7 +527,7 @@ class MediaRepository(object):
             defer.returnValue(output_path)
 
     @defer.inlineCallbacks
-    def _generate_thumbnails(self, server_name, media_id, file_id, media_info,
+    def _generate_thumbnails(self, server_name, media_id, file_id, media_type,
                              url_cache=False):
         """Generate and store thumbnails for an image.
 
@@ -534,14 +536,13 @@ class MediaRepository(object):
             media_id (str): The media ID of the content. (This is the same as
                 the file_id for local content)
             file_id (str): Local file ID
-            media_info (dict)
+            media_type (str)
             url_cache (bool): If we are thumbnailing images downloaded for the URL cache,
                 used exclusively by the url previewer
 
         Returns:
             Deferred[dict]: Dict with "width" and "height" keys of original image
         """
-        media_type = media_info["media_type"]
         requirements = self._get_thumbnail_requirements(media_type)
         if not requirements:
             return
diff --git a/synapse/rest/media/v1/preview_url_resource.py b/synapse/rest/media/v1/preview_url_resource.py
index 5ddf581bd2..981f01e417 100644
--- a/synapse/rest/media/v1/preview_url_resource.py
+++ b/synapse/rest/media/v1/preview_url_resource.py
@@ -187,7 +187,8 @@ class PreviewUrlResource(Resource):
         if _is_media(media_info['media_type']):
             file_id = media_info['filesystem_id']
             dims = yield self.media_repo._generate_thumbnails(
-                None, file_id, file_id, media_info, url_cache=True,
+                None, file_id, file_id, media_info["media_type"],
+                url_cache=True,
             )
 
             og = {
@@ -234,7 +235,8 @@ class PreviewUrlResource(Resource):
                     # TODO: make sure we don't choke on white-on-transparent images
                     file_id = image_info['filesystem_id']
                     dims = yield self.media_repo._generate_thumbnails(
-                        None, file_id, file_id, image_info, url_cache=True,
+                        None, file_id, file_id, image_info["media_type"],
+                        url_cache=True,
                     )
                     if dims:
                         og["og:image:width"] = dims['width']