Skip to content

User notifications, step 5: term and traffic notices - #100

Merged
limeflash merged 1 commit into
mainfrom
feat/user-notify-status
Dec 3, 2026
Merged

limeflash merged 1 commit into
mainfrom
feat/user-notify-status

Conversation

@limeflash

Copy link
Copy Markdown
Collaborator

Step 5 of user notifications (spec §5, §6, §15): the status kinds — expiry_soon, expired, quota_warn, quota_over, restored.

  • ResolveUserNoticeKind: mode, sound, channels and thresholds from the defaults, the global setting (notice.<kind>) and the person's override (notice_off).
  • Producer ProduceUserStatusNotices: one INSERT … SELECT per kind, all in one batch (one round trip a minute on the edge, an early exit when nobody has a chat). VPS: a loop; edge: a step of the tick before the sender.
  • Dedupe keys name the event (a renewal or a new quota period is a new event). No avalanche: only events after the person's first chat was linked and not older than 24 h. Telegram channel only (the app sees the term and the traffic itself). Off inserts nothing; ask inserts a pending draft (owner drafts come in step 7).
  • restored only after a sent expired or quota_over, once, when the access is active again by the stored status and by the clock.
  • The sender's registry gets the five kinds with texts and a "still true" check at send time. ru/en/zh verbatim from the owner's mockup; tr/fa need a native review; a quota without reset has its own variant without the date.
  • The edge tick has one more D1 batch: the counts in bridge.cjs and cron_js_test.go are updated.

Checks: go vet, go test (telegram, store, app, subs, access), test-edge-store.ps1, test-edge-entry.ps1, check-edge-sizes.sh (public headroom 113 KiB, jobs 155 KiB).

🤖 Generated with Claude Code

… quota_warn, quota_over, restored)

A producer looks at the state of the people once a minute and inserts the missing rows of user_notice, in SQL: one
INSERT ... SELECT per kind in one batch, so an edge tick costs one read (no person has a Telegram chat) or the settings
read plus one batch, whatever the number of people. The VPS runs it in a loop of Run, the edge in the tick before the
sender. A page is 100 rows per kind; the rest comes with the next call.

Keys: expiry_soon:<user>:<expires>:<days>, expired:<user>:<expires>, quota_warn:<user>:<period>:<pct>,
quota_over:<user>:<period>, restored:<id of the sent expired or quota_over row>. A renewal or a new quota period is a new
event. No avalanche: a row is made only for a person with a Telegram chat, for an event after their first chat was linked
and not older than 24 hours. The quota crossing has no stored time, so it is read off the hourly traffic (the hour is the
grain). The rows are for the Telegram channel only: the app sees the term and the traffic itself.

Settings: ResolveUserNoticeKind gives the mode (off/ask/auto), sound, channels and thresholds (days 3 and 1, percent 80)
from the defaults, the global "notice.<kind>" setting and the person's "notice_off" override. Off makes nothing, ask makes
a pending draft.

Sender: the five kinds with texts in ru, en, zh (the owner's) and tr, fa, with dates, days and gigabytes in the language of
the chat, and "still true" checks (a renewal, a new period or a raised quota take the notice back; restored only while the
access is active). Edge: the cron test counts one more D1 read per tick; no size limit raised.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@limeflash
limeflash merged commit d9f55b6 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