mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-26 23:19:24 -05:00
Move setting of file_id up to caller
This commit is contained in:
parent
5dfc83704b
commit
0a90d9ede4
@ -151,7 +151,7 @@ class MediaRepository(object):
|
|||||||
"media_length": content_length,
|
"media_length": content_length,
|
||||||
}
|
}
|
||||||
|
|
||||||
yield self._generate_thumbnails(None, media_id, media_info)
|
yield self._generate_thumbnails(None, media_id, media_id, media_info)
|
||||||
|
|
||||||
defer.returnValue("mxc://%s/%s" % (self.server_name, media_id))
|
defer.returnValue("mxc://%s/%s" % (self.server_name, media_id))
|
||||||
|
|
||||||
@ -413,7 +413,7 @@ class MediaRepository(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
yield self._generate_thumbnails(
|
yield self._generate_thumbnails(
|
||||||
server_name, media_id, media_info
|
server_name, media_id, file_id, media_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
defer.returnValue(media_info)
|
defer.returnValue(media_info)
|
||||||
@ -525,12 +525,15 @@ class MediaRepository(object):
|
|||||||
defer.returnValue(output_path)
|
defer.returnValue(output_path)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _generate_thumbnails(self, server_name, media_id, media_info, url_cache=False):
|
def _generate_thumbnails(self, server_name, media_id, file_id, media_info,
|
||||||
|
url_cache=False):
|
||||||
"""Generate and store thumbnails for an image.
|
"""Generate and store thumbnails for an image.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
server_name (str|None): The server name if remote media, else None if local
|
server_name (str|None): The server name if remote media, else None if local
|
||||||
media_id(str)
|
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_info (dict)
|
||||||
url_cache (bool): If we are thumbnailing images downloaded for the URL cache,
|
url_cache (bool): If we are thumbnailing images downloaded for the URL cache,
|
||||||
used exclusively by the url previewer
|
used exclusively by the url previewer
|
||||||
@ -539,10 +542,6 @@ class MediaRepository(object):
|
|||||||
Deferred[dict]: Dict with "width" and "height" keys of original image
|
Deferred[dict]: Dict with "width" and "height" keys of original image
|
||||||
"""
|
"""
|
||||||
media_type = media_info["media_type"]
|
media_type = media_info["media_type"]
|
||||||
if server_name:
|
|
||||||
file_id = media_info["filesystem_id"]
|
|
||||||
else:
|
|
||||||
file_id = media_id
|
|
||||||
requirements = self._get_thumbnail_requirements(media_type)
|
requirements = self._get_thumbnail_requirements(media_type)
|
||||||
if not requirements:
|
if not requirements:
|
||||||
return
|
return
|
||||||
|
@ -185,8 +185,9 @@ class PreviewUrlResource(Resource):
|
|||||||
logger.debug("got media_info of '%s'" % media_info)
|
logger.debug("got media_info of '%s'" % media_info)
|
||||||
|
|
||||||
if _is_media(media_info['media_type']):
|
if _is_media(media_info['media_type']):
|
||||||
|
file_id = media_info['filesystem_id']
|
||||||
dims = yield self.media_repo._generate_thumbnails(
|
dims = yield self.media_repo._generate_thumbnails(
|
||||||
None, media_info['filesystem_id'], media_info, url_cache=True,
|
None, file_id, file_id, media_info, url_cache=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
og = {
|
og = {
|
||||||
@ -231,8 +232,9 @@ class PreviewUrlResource(Resource):
|
|||||||
|
|
||||||
if _is_media(image_info['media_type']):
|
if _is_media(image_info['media_type']):
|
||||||
# TODO: make sure we don't choke on white-on-transparent images
|
# 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(
|
dims = yield self.media_repo._generate_thumbnails(
|
||||||
None, image_info['filesystem_id'], image_info, url_cache=True,
|
None, file_id, file_id, image_info, url_cache=True,
|
||||||
)
|
)
|
||||||
if dims:
|
if dims:
|
||||||
og["og:image:width"] = dims['width']
|
og["og:image:width"] = dims['width']
|
||||||
|
Loading…
Reference in New Issue
Block a user