Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images in backfed replies from Mastodon are unreliable #1675

Closed
davidcelis opened this issue Feb 26, 2024 · 3 comments
Closed

Images in backfed replies from Mastodon are unreliable #1675

davidcelis opened this issue Feb 26, 2024 · 3 comments

Comments

@davidcelis
Copy link

I've been backfeeding interactions from Mastodon back to my personal site for a while now, but I only started showing them off today. For the most part, everything is working great! However, if people reply to my post with an image, they pretty much never seem to load. An example can be seen on this post:

https://davidcel.is/notes/1756777068221628308

I was expecting this to happen for posts that get deleted (I have some friends/followers that auto-delete their posts after a certain amount of time). However, this happens regardless of whether or not the original post still exists. In this case, it does:

https://xoxo.zone/@danilo@hachyderm.io/111914757048130741

It looks like, at least at the time of this writing, that image lives here: https://xoxo-media.sfo2.cdn.digitaloceanspaces.com/cache/media_attachments/files/111/914/756/845/002/235/original/42975a5a216beae9.jpeg

My webmention, however, included this URL: https://xoxo-media.sfo2.cdn.digitaloceanspaces.com/cache/media_attachments/files/111/914/756/845/002/235/original/530f9cc4f42661f2.jpeg

My assumption is that this is because cached images in Mastodon typically have a retention period and that they're being destroyed, then re-cached whenever they're viewed again. This makes me wonder if it'd be better (if possible) for Bridgy to fetch the image from the post's server of origin? That way Bridgy users would get a persistent URL.

@davidcelis davidcelis changed the title Images in backfed replies from Mastodon are unreliablew Images in backfed replies from Mastodon are unreliable Feb 26, 2024
@snarfed
Copy link
Owner

snarfed commented Feb 26, 2024

Thanks for filing, and for the sleuthing! I think your guess is right.

Bridgy currently pulls image URL from media_attachments.url in the Mastodon API's status object: https://docs.joinmastodon.org/entities/MediaAttachment/ . This generally works, but you're right, if they're cached with a short expiration, and your webmention receiver doesn't have its own image cache, that's a problem.

Looks like remote_url, https://docs.joinmastodon.org/entities/MediaAttachment/#remote_url , is the source instance's URL. Hopefully it's more long lived? Definitely worth a try!

$ curl -v -H 'Authorization: Bearer ...' https://xoxo.zone/api/v1/statuses/111914757048130741
  ...
  "media_attachments": [
    {
      "id": "111914756845002235",
      "type": "image",
      "url": "https://xoxo-media.sfo2.cdn.digitaloceanspaces.com/cache/media_attachments/files/111/914/756/845/002/235/original/42975a5a216beae9.jpeg",
      "preview_url": "https://xoxo-media.sfo2.cdn.digitaloceanspaces.com/cache/media_attachments/files/111/914/756/845/002/235/small/42975a5a216beae9.jpeg",
      "remote_url": "https://media.hachyderm.io/media_attachments/files/111/914/756/560/090/313/original/e2c36af5ef792bba.jpeg",
   ...

@snarfed
Copy link
Owner

snarfed commented Feb 26, 2024

Deployed that fix. Thanks again for reporting @davidcelis!

@davidcelis
Copy link
Author

thanks for the quick fix, @snarfed! it's always a joy to open issues on bridgy (truly, no sarcasm 😄)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants