Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
H-Shay committed May 31, 2024
1 parent 7a3bac3 commit ca0a009
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions synapse/media/thumbnailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,10 @@ async def select_or_generate_remote_thumbnail(
desired_method: str,
desired_type: str,
max_timeout_ms: int,
ip_address: str,
) -> None:
media_info = await self.media_repo.get_remote_media_info(
server_name, media_id, max_timeout_ms
server_name, media_id, max_timeout_ms, ip_address
)
if not media_info:
respond_404(request)
Expand Down Expand Up @@ -422,12 +423,13 @@ async def respond_remote_thumbnail(
method: str,
m_type: str,
max_timeout_ms: int,
ip_address: str,
) -> None:
# TODO: Don't download the whole remote file
# We should proxy the thumbnail from the remote server instead of
# downloading the remote file and generating our own thumbnails.
media_info = await self.media_repo.get_remote_media_info(
server_name, media_id, max_timeout_ms
server_name, media_id, max_timeout_ms, ip_address
)
if not media_info:
return
Expand Down
2 changes: 2 additions & 0 deletions synapse/rest/client/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ async def on_GET(
respond_404(request)
return

ip_address = request.getClientAddress().host
remote_resp_function = (
self.thumbnailer.select_or_generate_remote_thumbnail
if self.dynamic_thumbnails
Expand All @@ -188,6 +189,7 @@ async def on_GET(
method,
m_type,
max_timeout_ms,
ip_address,
)
self.media_repo.mark_recently_accessed(server_name, media_id)

Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/media/thumbnail_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ async def on_GET(
) -> None:
# Validate the server name, raising if invalid
parse_and_validate_server_name(server_name)

set_cors_headers(request)
set_corp_headers(request)
width = parse_integer(request, "width", required=True)
Expand Down Expand Up @@ -121,4 +122,3 @@ async def on_GET(
ip_address,
)
self.media_repo.mark_recently_accessed(server_name, media_id)

0 comments on commit ca0a009

Please sign in to comment.