The bot-side half of TODO #4. Nothing federates yet; this establishes
what would be eligible to, and proves the boundary before there is a
hub that could leak across it.
- Schema v5 adds visibility, defaulting to private. Upgrading an
existing library therefore opts nothing into sharing, which a test
on the legacy upgrade path pins down.
- list_syncable() is the only function that will ever feed a hub, and
it requires both public and approved. Tests force rows into states
set_visibility refuses, so the filter is what protects the boundary
rather than the caller being careful.
- set_visibility refuses anything not approved: media still in the
moderation queue cannot be marked shared.
- /share lists memes with their current state and asks before making
one public, since un-sharing stops future copies but cannot recall
those already taken. The wording describes what sharing will mean
once a hub exists, because by then warning is too late.
- /list shows the same markers.
Vault posts have no path into the sync set at all; being in a separate
table is what guarantees it, and there is a test saying so.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Completes TODO #5. Forwarding a post now asks whether to save it whole
or extract its media; sending media directly is unchanged.
Built on forwarding rather than copying file_ids. The bot already has
the post in its private chat with the owner, so it stores message ids
and forwards them back. forwardMessages takes a list and keeps an album
intact, which is what made the caption-plus-album case tractable; ids
must be strictly ascending, so they are sorted on the way out.
- Vault rows live in their own table and every query is scoped to an
owner_id, so a guessed id cannot reach someone else's saved post.
Nothing in the vault is searchable inline, moderated or federated,
and the separate table makes that structural rather than a flag.
- Albums arrive as separate messages with no completion signal, so they
are buffered by media_group_id behind a 1s debounce and prompt once.
- The add path now takes a list of items, so extracting an album stores
every piece under one set of keywords instead of asking repeatedly.
- /vault searches keywords and the original caption, since the point of
a vault is finding something you never got round to tagging.
- Retrieval failures are reported: a message id is a pointer into the
chat, not a self-contained file_id, so clearing history breaks it.
Three near-identical keyword collectors are now one helper.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Completes TODO #3. Submissions are gated behind ACCEPT_SUBMISSIONS,
which defaults to off: is_allowed() treats everyone as allowed when
ALLOWED_USERS is empty, so opening submissions implicitly would have
accepted media from anyone who found the bot.
- Schema v3 adds status, reviewed_by and reviewed_at. Existing rows
default to approved, so upgrading changes nothing for a running bot.
- Search, /list and counts only return approved items; callers that
need everything pass status=None.
- /review shows the oldest pending item with approve, reject, fix
keywords and stop. No cursor is stored anywhere: each action just
asks for the next pending item, which is what lets a moderator stop
and resume later, and lets several moderators share one queue.
- set_status only updates rows still pending, so if two moderators open
the same item the first decision wins and the second is told so.
- A failed send no longer wedges the queue; the item's details are
shown anyway so it can still be rejected.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Step 0 of the roadmap: everything from the moderation queue onward adds
columns, and init_db could only ever run CREATE TABLE IF NOT EXISTS, so
it could not alter a live deployment.
- Track schema state in PRAGMA user_version and run ordered migrations.
Fresh installs create the v1 table and migrate forward, so the upgrade
path runs on every new deployment rather than only on old ones.
- Rebuild media with UNIQUE(owner_id, file_unique_id). The old global
unique constraint stopped two users from each saving the same file,
which blocks public mode.
- Replace INSERT OR REPLACE with an upsert. Replacing deleted and
reinserted the row, giving it a new id and silently invalidating any
id the user had noted from /list.
- Give search_media an optional owner_id scope, defaulting to the
current shared-library behaviour.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>