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

Why does the bot not handle boosting toots with image captions added in an edit? #12

Open
fasiha opened this issue Jul 9, 2023 · 1 comment

Comments

@fasiha
Copy link
Collaborator

fasiha commented Jul 9, 2023

Example: when boosting https://mastodon.social/@cacheflowe/110672863305088428 the bot receives the following message (with account sections elided):

{
  event: 'update',
  data: {
    id: '110681412771637519',
    created_at: '2023-07-09T00:58:50.000Z',
    in_reply_to_id: null,
    in_reply_to_account_id: null,
    sensitive: false,
    spoiler_text: '',
    visibility: 'public',
    language: null,
    uri: 'https://sfba.social/users/22/statuses/110681412744698561/activity',
    url: null,
    replies_count: 0,
    reblogs_count: 0,
    favourites_count: 0,
    edited_at: null,
    content: '',
    reblog: {
      id: '110672863357802426',
      created_at: '2023-07-07T12:44:36.000Z',
      in_reply_to_id: null,
      in_reply_to_account_id: null,
      sensitive: false,
      spoiler_text: '',
      visibility: 'public',
      language: 'en',
      uri: 'https://mastodon.social/users/cacheflowe/statuses/110672863305088428',
      url: 'https://mastodon.social/@cacheflowe/110672863305088428',
      replies_count: 1,
      reblogs_count: 25,
      favourites_count: 0,
      edited_at: null,
      content: '<p>Looking for magic numbers</p>',
      reblog: null,
      account: {},
      media_attachments: [
        {
          id: '110672877791131601',
          type: 'gifv',
          url: 'https://files.botsin.space/cache/media_attachments/files/110/672/877/791/131/601/original/32fb61799833392b.mp4',
          preview_url: 'https://files.botsin.space/cache/media_attachments/files/110/672/877/791/131/601/small/32fb61799833392b.png',
          remote_url: 'https://files.mastodon.social/media_attachments/files/110/672/862/713/361/799/original/b3632ff29ba7daee.mp4',
          preview_remote_url: null,
          text_url: null,
          meta: {
            original: {
              width: 910,
              height: 1080,
              frame_rate: '30/1',
              duration: 33.134,
              bitrate: 2990417
            },
            small: {
              width: 337,
              height: 400,
              size: '337x400',
              aspect: 0.8425
            }
          },
          description: null,
          blurhash: 'U87^xsxZRiRj0MNdRkjs-TxDxtofRkR+bIRk'
        }
      ],
      mentions: [],
      tags: [],
      emojis: [],
      card: null,
      poll: null,
      favourited: false,
      reblogged: false,
      muted: false,
      bookmarked: false,
      filtered: []
    },
    account: {},
    media_attachments: [],
    mentions: [],
    tags: [],
    emojis: [],
    card: null,
    poll: null,
    muted: false,
    bookmarked: false,
    filtered: [],
    favourited: false,
    reblogged: false
  }
}

Note how the data.reblog.media_attachments[0].description is indeed null.

Even when I request the statuses endpoint directly for this post, i.e., curl -H "Authorization: Bearer $MASTODON_ACCESS_TOKEN" $MASTODON_API_URLstatuses/110672863357802426, I got the same payload as above, with description set to null.

But curiously, after a few minutes of experimenting, I noticed in the browser that hitting that same endpoint now returns JSON with the "description": "Time-lapse video of a …",! Therefore, if I unboost and reboost the same toot, the bot doesn't warn me.

Here's what I think is going on. Hypothesis: when a user boosts a toot, botsin.space doesn't get the contents of the toot at the time of the boost but a "smaller" payload with just the toot ID. Botsin.space has already seen that toot ID—it's in its cache—so it doesn't look for any edits. When someone that PleaseCaption bot follows boosts the toot, botsin.space gives the bot the old cached copy. But later, if I search for the toot while on botsin.space, then it will go out to the original instance and look for edits.

Hypothesis 2: hitting the context or search endpoints makes botsin.space search the original server for any edits.

  • After the warns me (incorrectly) for boosting another edited-to-add-alt-text toot, when I search for that toot in the botsin.space Mastodon web client, the search endpoint returns the edited toot, so if I unboost and reboost it, the bot is happy. So search is probably checking for edits. Edit confirmed hitting the api/v2/search endpoint with resolve=true and the query as the boosted toot URL directly yields the toot status with the updated image description.
  • hitting context or history endpoints do NOT result in botsin.space finding the edited toot.

Therefore we may have to hit the search?resolve=true endpoint (with limit=1 and type=statuses to minimize the workload) when we find a boosted toot without image captions in order to detect edits…

@zactopus do you know of any details about how edits are propagated server-to-server and if there's any alternative to the search proposal above?

(Background aside: I know I've boosted toots after alt text were added, and the bot didn't complain, e.g., https://mastodon.social/@Manigarm/110576935488724453. I don't think the author of the original toot follows the bot, so her edit wouldn't have directly flowed to botsin.space. So there's some mechanism by which some/many edits make it to the instance. I'd like to know more about how that happens.)

@zoetrope69
Copy link
Owner

I think your approach makes sense, I am a bit worried about hitting rate limits with additional calls. Maybe it's time to write a queue system finally lol.

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