From cf69f8d59b0a1fad2b0f313281647e3ea527cf5e Mon Sep 17 00:00:00 2001 From: Shay Date: Mon, 8 Jul 2024 02:11:20 -0700 Subject: Support MSC3916 by adding a federation /thumbnail endpoint and authenticated `_matrix/client/v1/media/thumbnail` endpoint (#17388) [MSC3916](https://github.com/matrix-org/matrix-spec-proposals/pull/3916) added the endpoints `_matrix/federation/v1/media/thumbnail` and the authenticated `_matrix/client/v1/media/thumbnail`. This PR implements those endpoints, along with stabilizing `_matrix/client/v1/media/config` and `_matrix/client/v1/media/preview_url`. Complement tests are at https://github.com/matrix-org/complement/pull/728 --- synapse/media/media_repository.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'synapse/media/media_repository.py') diff --git a/synapse/media/media_repository.py b/synapse/media/media_repository.py index 542642b900..87c929eb20 100644 --- a/synapse/media/media_repository.py +++ b/synapse/media/media_repository.py @@ -542,7 +542,12 @@ class MediaRepository: respond_404(request) async def get_remote_media_info( - self, server_name: str, media_id: str, max_timeout_ms: int, ip_address: str + self, + server_name: str, + media_id: str, + max_timeout_ms: int, + ip_address: str, + use_federation: bool, ) -> RemoteMedia: """Gets the media info associated with the remote file, downloading if necessary. @@ -553,6 +558,8 @@ class MediaRepository: max_timeout_ms: the maximum number of milliseconds to wait for the media to be uploaded. ip_address: IP address of the requester + use_federation: if a download is necessary, whether to request the remote file + over the federation `/download` endpoint Returns: The media info of the file @@ -573,7 +580,7 @@ class MediaRepository: max_timeout_ms, self.download_ratelimiter, ip_address, - False, + use_federation, ) # Ensure we actually use the responder so that it releases resources -- cgit 1.5.1