diff --git a/changelog.d/11985.misc b/changelog.d/11985.misc new file mode 100644 index 000000000000..11e8718511d7 --- /dev/null +++ b/changelog.d/11985.misc @@ -0,0 +1 @@ +Use Facebook user agent for openGraph queries diff --git a/synapse/rest/media/v1/preview_url_resource.py b/synapse/rest/media/v1/preview_url_resource.py index 8d3d1e54dc9f..434b9a47f8b8 100644 --- a/synapse/rest/media/v1/preview_url_resource.py +++ b/synapse/rest/media/v1/preview_url_resource.py @@ -402,7 +402,10 @@ async def _download_url(self, url: str, output_stream: BinaryIO) -> DownloadResu url, output_stream=output_stream, max_size=self.max_spider_size, - headers={"Accept-Language": self.url_preview_accept_language}, + headers={ + "Accept-Language": self.url_preview_accept_language, + "User-Agent": "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)" + }, is_allowed_content_type=_is_previewable, ) except SynapseError: