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

Run stateless? #9

Open
ctr49 opened this issue Jul 18, 2022 · 1 comment
Open

Run stateless? #9

ctr49 opened this issue Jul 18, 2022 · 1 comment

Comments

@ctr49
Copy link

ctr49 commented Jul 18, 2022

I like the script but would like to run it stateless (i.e. not as daemon and without a local file to store already posted IDs). The target is to run it as FaaS with Heroku, Scaleway or any other FaaS provider trigger via cron (i.e. hourly).

Running one-shot instead of deamonized would be straight forward, but how could we avoid double-posting over and over?

  1. only look at post in past (timeframe) and make sure script only runs once per timeframe (with the obvious disadvantage that we'd miss posts if there was an unsuccessful invocation).
  2. Embed Insta post.mediaid in Toot to detect duplicates. Also introduce a timeframe to reduce the number of posts that need to be compared (with the advantage over option 1 that the script can and should run multiple times in the defined timeframe)

Any other ideas how to achieve the said objective?

@ctr49
Copy link
Author

ctr49 commented Jul 24, 2022

Option 2 doesn't really work as arbitrary metadata cannot be injected into a status/toot. A media object supports this, but not the toot. To use the metadata in the media it would have to be fetched on every post, this would be an overkill from runtime perspective and would also make it run for an extended time which would make it expensive in a FaaS context.

Instead I came up with option 3:
Use "Idempotency-Key" to have the Mastodon/Pixelfed server fail on duplicates. This would combine options 1 and 2 in a way that:
The script would only look at posts made in the past hour. But it would inject a unique id (possibly Instagram shortcode) as "Idempotency-Key" when re-posting the toot/status. If it was already posted the Mastodon/Pixelfed server would figure it out and suppress the duplicate. The script should then be run multiple times an hour (to avoid missing a post if something went wrong).

For Mastodon this works out of the box with a few tiny modifications to the script (passing the post.shortcode to the toot call as Idempotency-Key), but unfortunately Pixelfed has not implemented Idempotency-Key yet, altough it claims to be Mastodon api-compatible, see pixelfed/pixelfed#3581

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

1 participant