Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Use Facebook user agent for openGraph queries
Browse files Browse the repository at this point in the history
We found that some websites return opengraph information based
on the user agent.  Since Facebook is the creator of opengraph,
using the Facebook user agent when requesting the opengraph metadata
should work in the widest variety of situations.
https://developers.facebook.com/docs/sharing/webmasters/#user-agent

Signed-off-by: Andrew Ryan <andrewryanchama@clover.club>
  • Loading branch information
Andrew Ryan authored and tenpura-shrimp committed Feb 13, 2022
1 parent 55113dd commit 98e3c89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/11985.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use Facebook user agent for openGraph queries
5 changes: 4 additions & 1 deletion synapse/rest/media/v1/preview_url_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 98e3c89

Please sign in to comment.