Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
0a90d9ed
"git@mau.dev:maunium/synapse.git" did not exist on "4655d2221e79b0ecdcb88c7e1eef467eec2ed481"
Commit
0a90d9ed
authored
7 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Move setting of file_id up to caller
parent
5dfc8370
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/rest/media/v1/media_repository.py
+10
-11
10 additions, 11 deletions
synapse/rest/media/v1/media_repository.py
synapse/rest/media/v1/preview_url_resource.py
+4
-2
4 additions, 2 deletions
synapse/rest/media/v1/preview_url_resource.py
with
14 additions
and
13 deletions
synapse/rest/media/v1/media_repository.py
+
10
−
11
View file @
0a90d9ed
...
...
@@ -151,7 +151,7 @@ class MediaRepository(object):
"
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
))
...
...
@@ -413,7 +413,7 @@ class MediaRepository(object):
}
yield
self
.
_generate_thumbnails
(
server_name
,
media_id
,
media_info
server_name
,
media_id
,
file_id
,
media_info
,
)
defer
.
returnValue
(
media_info
)
...
...
@@ -525,24 +525,23 @@ class MediaRepository(object):
defer
.
returnValue
(
output_path
)
@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.
Args:
server_name(str|None): The server name if remote media, else None if local
media_id(str)
media_info(dict)
url_cache(bool): If we are thumbnailing images downloaded for the URL cache,
server_name (str|None): The server name if remote media, else None if local
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)
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
"
]
if
server_name
:
file_id
=
media_info
[
"
filesystem_id
"
]
else
:
file_id
=
media_id
requirements
=
self
.
_get_thumbnail_requirements
(
media_type
)
if
not
requirements
:
return
...
...
This diff is collapsed.
Click to expand it.
synapse/rest/media/v1/preview_url_resource.py
+
4
−
2
View file @
0a90d9ed
...
...
@@ -185,8 +185,9 @@ class PreviewUrlResource(Resource):
logger
.
debug
(
"
got media_info of
'
%s
'"
%
media_info
)
if
_is_media
(
media_info
[
'
media_type
'
]):
file_id
=
media_info
[
'
filesystem_id
'
]
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
=
{
...
...
@@ -231,8 +232,9 @@ class PreviewUrlResource(Resource):
if
_is_media
(
image_info
[
'
media_type
'
]):
# 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
,
image_info
[
'
filesystem
_id
'
]
,
image_info
,
url_cache
=
True
,
None
,
file_id
,
file
_id
,
image_info
,
url_cache
=
True
,
)
if
dims
:
og
[
"
og:image:width
"
]
=
dims
[
'
width
'
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment