Post Tool
A small scheduled Worker that mirrors a Facebook Page to Bluesky and adds the first comment on posts.
What it does
- Every 15 minutes it reads the Page's ten latest posts and mirrors anything newer than the last one it handled, oldest first so order is preserved.
- Images are uploaded as Bluesky embeds; if the image fails, the text still posts.
- Posts over 300 characters become a thread split on word boundaries, with an (i/n) marker. Links in the text become clickable facets.
- First comments: a manager queues the opening words of a scheduled post plus a comment in the admin tool. When a matching post appears, the Worker comments on Facebook and replies in the Bluesky thread.
Design decisions
- Best effort, bounded retries. A failing post is retried on the next run, up to three runs, then skipped so it cannot block newer posts.
- No backfill. On its first ever run it records the newest post as a starting point instead of replaying history.
- Per-platform progress. Each platform's result is stored separately, so a failure on one is retried without double-commenting on the other.
- Fuzzy but safe matching. Case, quote and whitespace-insensitive prefix match; the longest entry wins, a post claims one entry and an entry one post. Entries not completed within 14 days of being queued are ignored and shown as expired.
- Shared database, one owner. It binds the admin tool's D1 database but only updates progress columns; the admin tool owns the schema.
Under the hood
- A single Worker of about 600 lines on a cron trigger, with KV for the last-mirrored marker and Bluesky thread references, and D1 for first comments.
- Unit tests use a fake database and fake Facebook and Bluesky responses. They prove the logic, not that the live services accept the calls.
- Known gap: if the Facebook token expires it fails silently, as there is no alert yet.