Repository navigation
User notifications, step 5: term and traffic notices - #100
Merged
Merged
Conversation
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).ProduceUserStatusNotices: oneINSERT … SELECTper 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.restoredonly after a sentexpiredorquota_over, once, when the access is active again by the stored status and by the clock.bridge.cjsandcron_js_test.goare 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