-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Repair URL preview for tweets, may require a logged in Twitter account #7643
Comments
Somehow Facebook's URL previews still work for tweets. |
I assume Facebook is also using a Twitter account to render tweet previews then. |
I was curious so I took a closer look. I think Twitter are accommodating Facebook on their end. If you use Facebook's user-agent string, Twitter serves completely different HTML. |
Can confirm, patched
with self.media_storage.store_into_file(file_info) as (f, fname, finish):
try:
logger.debug("Trying to get preview for url '%s'", url)
length, headers, uri, code = await self.client.get_file(
url,
output_stream=f,
max_size=self.max_spider_size,
headers={"Accept-Language": self.url_preview_accept_language,
"User-Agent": ["facebookexternalhit/1.0 (+http://www.facebook.com/externalhit_uatext.php)"]},
) And now I have tweet previews again. It's not a solution but a nice workaround until a proper one appears. |
Is matrix going to create an overall account to fix that for us all or merge this workaround any time soon? |
I think the best way forward might be for Synapse to fetch the oEmbed from Twitter and massage that, rather than these sorts of workarounds. I suspect becoming a Twitter app might not be a great idea - the quotas would likely get exhausted very quickly. |
The given workaround isn't really reasonable to merge into Synapse, we also don't want to add workarounds for specific sites like this. Using something like oEmbed would likely be a sane way to improve the current embedding. |
Are there arguments against doing that? |
I myself would be against it, lol. It solves an issue for a single website (even though it's a very popular one) using a fake misleading user agent. It's clearly a temporary solution for server operators that need it to work right now but it's not general enough to make it to the upstream. It can also break previews for some other sites that, for example, block Facebook from indexing them (for whatever reason, like privacy). There are many issues with this hack even though it works for now. It may stop working if tomorrow Twitter changes something again. Using oEmbed would be better of course, but from my understanding it would require custom requests that are different for every website that supports it. So it requires significant work anyway (to generalize this approach) and I wouldn't expect a non-hack solution soon considering it's p2. |
Related: #2752 |
@ara4n take (paraphrased) |
@neilisfragile / @ara4n: surely using the oembed api link would be preferable to supplying an account? |
Too bad Twitter doesn't provide oEmbed discovery as per https://oembed.com/#section4 so this API endpoint must be explicitly specified for Twitter in Synapse somewhere. |
Would using Noembed be sensible? |
One thing pointed out by thelounge/thelounge#3602 is that the user-agent approach, in the great tradition of terrible user-agent hacks through history, is being used by Apple for all link previews in iMessage. As a result, it may actually end up being a regrettable Schelling point of compatibility, as all sites which want link previews to work on iOS will add support for that user agent being used in this manner. One notable aspect, here, is that unlike some of the alternative proposals (such as letting the user unfurl by providing a twitter account), this preserves anonymity. |
for now we're just going to turn off url previews for twitter 🤷♂️ |
Is it possible to somehow opt-out from turning them off? I prefer to keep this workaround on my homeserver since it works for me and I post tweet links often. |
@neilisfragile: were you envisaging that we just disable it for matrix.org (which we can do via config), or for everyone? |
I'm not familiar with that: it looks like it involves sending all preview requests via their hosted platform? I think many matrix users would be unhappy with that |
ok, change of plan: we're going to try special-casing twitter url previews to use their oembed api. Hopefully that will solve the problem. |
As of a few days ago, URL previews for tweets have stopped working on matrix.org. Instead of a preview of the tweet, we get the following instead:
After discussing with @michaelkaye, he pointed out that other apps (such as Slack) seem to require a Twitter account for their tweet previewing integration. Perhaps something has changed on Twitter's side such that we'll also need to provide an account for Synapse to preview tweets?
The text was updated successfully, but these errors were encountered: