WebHooker/docs/guide/tasks.md
RhenCloud 25ebae4ae5
feat(storage): migrate config, dedup and delivery state to D1
- Move oversized queue payloads from KV to R2 (PAYLOAD binding, webhooks/YYYY/MM/DD/*.json, KV queue:payload:* fallback)
- Persist routes/groups to D1 (d1_routes/d1_groups) with memory -> KV -> D1 three-tier cache, seeded from legacy KV config keys
- Move webhook dedup (dedup_keys), delivery state (delivery_state) and message tracking (message_tracking) to D1 via canUseD1 probe with automatic KV fallback
- Batch send_logs inserts (recordSendBatch) and add group_id/ts index
- Add storage-prune scheduled task for expired dedup/state/tracking rows
- Add TTL to invite:group:{id} index and audit all ephemeral KV keys
- Add D1 indexes for the new tables
- Sync AGENTS.md, README.md/zh and docs/ (en/zh) with the new storage layout
2026-08-17 15:01:20 +08:00

1.2 KiB

Scheduled Tasks

WebHooker runs four maintenance tasks on the scheduled trigger (*/5 * * * *, every 5 minutes). They only run on the deployed worker (Cloudflare cron); local wrangler dev runs them when triggered via wrangler dev --test-scheduled.

Task Purpose
discord-sync Registers the Discord slash/context-menu commands: per-guild (instant) and globally (24h dedup, ~1h propagation)
telegram-sync Calls setWebhook to {BASE_URL}/telegram/webhook (with TELEGRAM_WEBHOOK_SECRET as secret_token when set)
audit-prune Deletes audit_logs entries older than AUDIT_RETENTION_DAYS (default 90)
storage-prune Deletes expired dedup_keys rows, delivery_state rows older than 7 days and message_tracking rows older than 30 days

There is nothing to configure beyond the secrets the tasks use (DISCORD_TOKEN, DISCORD_APPLICATION_ID, TELEGRAM_TOKEN, BASE_URL, AUDIT_RETENTION_DAYS).