diff options
author | Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> | 2020-04-15 13:35:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-15 13:35:29 +0100 |
commit | a48138784ea20dd8d8a68ce5c3563da6f3fbde43 (patch) | |
tree | 24cb8055a17659b04af5b5ef271457969e8b85fa /synapse/rest/media/v1 | |
parent | Fix a potentially-huge sql query (#7274) (diff) | |
download | synapse-a48138784ea20dd8d8a68ce5c3563da6f3fbde43.tar.xz |
Allow specifying the value of Accept-Language header for URL previews (#7265)
Diffstat (limited to 'synapse/rest/media/v1')
-rw-r--r-- | synapse/rest/media/v1/preview_url_resource.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/synapse/rest/media/v1/preview_url_resource.py b/synapse/rest/media/v1/preview_url_resource.py index c46676f8fc..f68e18ea8a 100644 --- a/synapse/rest/media/v1/preview_url_resource.py +++ b/synapse/rest/media/v1/preview_url_resource.py @@ -86,6 +86,7 @@ class PreviewUrlResource(DirectServeResource): self.media_storage = media_storage self.url_preview_url_blacklist = hs.config.url_preview_url_blacklist + self.url_preview_accept_language = hs.config.url_preview_accept_language # memory cache mapping urls to an ObservableDeferred returning # JSON-encoded OG metadata @@ -315,9 +316,12 @@ class PreviewUrlResource(DirectServeResource): with self.media_storage.store_into_file(file_info) as (f, fname, finish): try: - logger.debug("Trying to get url '%s'", url) + logger.debug("Trying to get preview for url '%s'", url) length, headers, uri, code = await self.client.get_file( - url, output_stream=f, max_size=self.max_spider_size + url, + output_stream=f, + max_size=self.max_spider_size, + headers={"Accept-Language": self.url_preview_accept_language}, ) except SynapseError: # Pass SynapseErrors through directly, so that the servlet |