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.
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
EventStoretoEventWorkerStore.". - 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.
- 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
- [X] Code style is correct (run the linters)
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 |
|---|---|
(The site image not loading is an unrelated issue.)
I'm pretty sure this regresses another site, maybe Twitter? I forgot why we started combining them like that.
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 :/
Here's some more test sites:
YouTube
The broken YouTube previews are fixed too, woo!
| Before | After |
|---|---|
It looks like this hasn't changed at all, which is good.
| Before | After |
|---|---|
GitHub
This is also identical.
| Before | After |
|---|---|
This seems related to #17462. Do you think it will help with that issue as well, or is that an additional problem?
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)