Skip to content

User notifications, step 3: the sender of the notices to people - #98

Merged
limeflash merged 3 commits into
mainfrom
feat/user-notify-send
Dec 3, 2026
Merged

limeflash merged 3 commits into
mainfrom
feat/user-notify-send

Conversation

@limeflash

Copy link
Copy Markdown
Collaborator

Step 3 of user notifications (spec §5, §15): the sender of user_notice through the people's bot.

  • VPS: a constant loop; edge: a bounded pass in the tick, after one cheap read that says whether anything is due.
  • Only rows with the Telegram channel bit are leased; app-only rows stay for sync (step 11).
  • One message per chat of a person gathers what is due; language of the chat, else the panel's; loud if any notice is loud; a muted chat skips broadcasts only.
  • Kind registry (text + "still true" check), empty for now: kinds come in steps 5–9. Unknown kind → dropped, stale → skipped_stale.
  • Pace 20/s per bot, 1/s per chat. 429 → back at retry_after; 401 → "unauthorized" on the bot card, queue waits; both spend no attempt. 5xx/network → 1, 2, 4 … 64 min, dropped after 8. 403/chat not found → chat forgotten, unlinked if none left.
  • tg_message_refs by chat row id (never the Telegram chat id); a retry skips chats that already got it. A pass ends within half its lease.
  • RPC TestUserTelegramChat (owner and helper): the "Test" button of a chat, one per 10 s per chat.

Checks: go vet/test (telegram, store, auth, app), buf, test-edge-store.ps1, check-edge-sizes.sh (jobs headroom 253 KiB, admin 2100 KiB, public 187 KiB).

🤖 Generated with Claude Code

limeflash and others added 3 commits December 3, 2026 18:55
The outbox user_notice now drains through the people's bot. A pass leases the due rows that have the Telegram channel
(a row for the app alone is never leased: the app pulls it), gathers one person's rows into one message per chat in the
chat's language (panel language when it has none), loud when any line is loud and disable_notification otherwise, and
skips announcements for a chat that said /mute. Kinds come from a registry (text and "still true" check) that the later
steps fill; an unknown kind is dropped with a code, a stale one is skipped_stale.

Pace is 20 messages a second per bot and one a second per chat. 429 stops the pass and puts the rows back at retry_after;
a refused token (401) writes "unauthorized" on the bot's card and the queue waits, neither spends an attempt. 5xx or no
answer retries after 1, 2, 4 ... 64 minutes and drops on the eighth failure. 403 or "chat not found" forgets the chat,
and a person left with none gets "unlinked". The message ids are kept per chat row id (never the Telegram chat id), so a
retry after a partial send does not repeat to the chats that have it. A pass cut short puts its rows back at once.

The VPS runs the pass in a loop of Run; the edge tick runs one bounded pass after a one-row read (HasDueUserNotices).

"Test" button of a chat: UserNotifyService.TestUserTelegramChat (owner and helper, like Unlink) sends a fixed text in the
chat's language at once, outside the outbox; a blocked bot unlinks the chat. Texts in ru/en/zh/tr/fa.

Edge: jobs Worker +87 KiB (253 KiB left under its limit), admin +36 KiB, public +16 KiB; no limit raised. The cron test
counts one more D1 read per tick.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…let the next pass send the same notices again

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ces due to people

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@limeflash
limeflash merged commit 1b9a5e2 into main Dec 3, 2026
9 checks passed
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

Successfully merging this pull request may close these issues.

1 participant