synapse icon indicating copy to clipboard operation
synapse copied to clipboard

Fix Mastodon URL previews not showing anything useful

Open redstrate opened this issue 3 weeks ago • 2 comments

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.

Pull Request Checklist

  • [X] Pull request is based on the develop branch
  • [X] Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • [X] Code style is correct (run the linters)

redstrate avatar Nov 26 '25 19:11 redstrate

For more context, Mastodon puts part of the post into og:description. Here's also a side-by-side of the difference in information:

Before After
image image

(The site image not loading is an unrelated issue.)

redstrate avatar Nov 26 '25 20:11 redstrate

I'm pretty sure this regresses another site, maybe Twitter? I forgot why we started combining them like that.

clokep avatar Nov 26 '25 22:11 clokep

I'm pretty sure this regresses another site, maybe Twitter? I forgot why we started combining them like that.

I'll try a few more sites and see what changes, I'm also worried about regressing some site I don't know about :/

redstrate avatar Nov 27 '25 00:11 redstrate

Here's some more test sites:

YouTube

The broken YouTube previews are fixed too, woo!

Before After
image image

Twitter

It looks like this hasn't changed at all, which is good.

Before After
image image

GitHub

This is also identical.

Before After
image image

redstrate avatar Nov 27 '25 00:11 redstrate

This seems related to #17462. Do you think it will help with that issue as well, or is that an additional problem?

devonh avatar Nov 28 '25 15:11 devonh

This seems related to #17462. Do you think it will help with that issue as well, or is that an additional problem?

It looks like it does help that issue indeed, the buggy behavior matches up with what I see now. But with this patch it looks correct (see the YT section above)

redstrate avatar Nov 28 '25 16:11 redstrate