Skip to content

Commit 308ceff

Browse files
committed
Fix Mastodon URL previews not showing anything useful
Fixes #18444. Inside of UrlPreviewer, we need to combine two dicts (one from oEmbed, and one from HTML) and in Mastodon's case they were very different. The one from HTML is basically useless, due to it being a Javascript application. But the oEmbed one has the actual post content, yet the information from HTML was preferred. So I flipped which dictionary overlays which, so keys from oEmbed is preferred over the extracted HTML ones. This seems to be the original intention judging by the comment. I also updated to the newer Python synax for merging dictionaries.
1 parent 703464c commit 308ceff

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

changelog.d/19231.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug where Mastodon posts (and possibly other embeds) have the wrong description for URL previews.

synapse/media/url_previewer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ async def _do_preview(self, url: str, user: UserID, ts: int) -> bytes:
331331
# Compile the Open Graph response by using the scraped
332332
# information from the HTML and overlaying any information
333333
# from the oEmbed response.
334-
og = {**og_from_html, **og_from_oembed}
334+
og = og_from_oembed | og_from_html
335335

336336
await self._precache_image_url(user, media_info, og)
337337
else:

0 commit comments

Comments
 (0)