HTTP API: register, list and remove webhooks, kept across restarts #6
Notifications
Due Date
No due date set.
Blocks
Depends on
#2 Exponentiation, modulo, HTTP API for chats, per-chat webhooks
sneak/simplexcalc
#7 Webhooks: post each new incoming message
sneak/simplexcalc
#5 HTTP API: a chat's recent messages, and sending a message
sneak/simplexcalc
Reference: sneak/simplexcalc#6
Reference in New Issue
Block a user
Part of #2. Builds on #5 and starts from
nextonce that is merged.What. An external app registers webhooks on a chat, lists them, and removes one. Registrations survive a restart. Posting messages to them is the next unit.
Decisions (reversible, taken by the repo-manager):
POST /api/v1/chats/{id}/webhookswith{"url":"..."}returns201and{"id":"...","chat_id":{id},"url":"..."}; the id is 16 random bytes in hex. The URL must be absolutehttporhttpswith a host, at most 2048 bytes; otherwise400. A chat that is not one of the bot's contacts is404. The same URL already registered on that chat returns200with the existing registration.GET /api/v1/chats/{id}/webhooksreturns{"webhooks":[...]}.DELETE /api/v1/chats/{id}/webhooks/{webhook_id}returns204, or404.$DATA_DIR/webhooks.json, mode 0600, rewritten whole on each change through a temporary file in the same directory and a rename, so a crash leaves the old file or the new one, never half of one. Read at startup: absent means no webhooks; present but unparseable aborts startup, like configuration.Done when:
400and404cases, and a registration surviving a new store read from the same directory.curlexamples, and the file under Operating it (Backup).docs/TODO.mdCompleted Steps gets a line.make checkis green.Model: opus-5-5