Repository navigation
User notifications, step 2: the people's bot - #97
Merged
Merged
Conversation
…f the people needs UserTelegramStats (people with a chat, chats, last delivery) for the card of the bot, UserTelegramCodeExpiry and DeleteUserTelegramCode for the "waiting for the link" state and for withdrawing a code, UserExists to tell a missing person from a person with no chats. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…inking, commands) The second Telegram bot of the panel (spec notifications-panel-spec, PR 2): the owner sets it, a person links a chat with a one-time code, and the chat can stop or mute itself. No sender, no triggers, no UI yet. API (TelegramService, so the admin Worker takes no new service): - GetUserBot (state of the card, counts, last delivery, chat limit), SetUserBot and ClearUserBot (owner, step-up; the token goes sealed to the vault and never comes back; a bot the owner already uses is refused: user_bot_same_as_owner, and the owner's SetTelegramBot refuses the people's bot the same way). - BeginUserTelegramLink / CancelUserTelegramLink (owner or helper): 128-bit code, only its hash stored, 15 minutes, one per person, answered as a t.me link. - ListUserTelegramChats, UnlinkUserTelegramChat, SetUserTelegramChatMuted by chat row id: no Telegram chat id leaves the panel. - SetUserTelegramChatLimit (owner): the limit of everybody (default 3, 1 to 10) or of one person, keys telegram_chat_limit. Receiving: its own offset in user_telegram_bot. The VPS long polls for ever; the edge polls only while a link code of a person waits (HasPendingUserTelegramCode) and under the lease user-telegram-poll, after the poll of the owner's bot in EdgeTick. The state of a failed poll is a code on the bot row (unauthorized, unreachable, conflict, same_as_owner), never Telegram's text. Commands: /start <code> links the chat (language from Telegram, else the panel's; five languages ru, en, zh, tr, fa), greets, tells the person's other chats and audits it; a bad code, a chat of another person and a full person each get a short reason. /stop unlinks, /mute switches the announcements, /unmute (hidden) only switches them on. An unlinked chat gets no answer, a group none, an admin's chat nothing. A 403 or "chat not found" on any answer unlinks the chat. The sealed chat id is bound to its chat MAC (the row id is born inside the store insert); the restore check of the sealed columns learns the bot token and the chat id, and its golden test links a chat through the real path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The people's bot added a second D1 read to every minute tick, and the cron test counts those. PendingTelegramLinkCodes asks in one query whether an admin's or a person's code waits, and PollPendingLinkCodes polls only the bot that has one, each within its own 40 s; the tick makes one call to it. PollPendingLinkCode and PollPendingUserLink keep their own check for a caller on its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…admin Worker only The calls of the bot of the people and a person's chats move out of adminv1.TelegramService into mistgate.usernotify.v1.UserNotifyService (11 messages instead of 24). Only the roles that serve the admin API link it: app.Config.UserNotifyAPI takes usernotifyrpc.Handler, as ProposalAPI takes proposalrpc, and Build and BuildAdmin refuse a Config without it. The public, link, jobs and provision Workers no longer carry its generated code and descriptors (go list -deps shows none of it there). telegram.Service keeps the work as proto-free methods (user_admin.go) and checks who may call; the new usernotifyrpc package only maps them to messages. Procedures are named by path in auth/policy_usernotify.go, pinned to the generated names by a test; the hardening test walks the new package too. The backup golden test and the role tests use the new service. 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 2 of user notifications (spec §13, §15): the people's Telegram bot.
mistgate.usernotify.v1(UserNotifyService), served by the admin Worker only./start <code>;/stop,/mutetoggles,/unmutehidden synonym. Other chats of the person are told about a new link.Checks: go vet and tests (telegram, auth, app, store, backup, vendorcheck),
check-edge-sizes.sh(admin headroom 2135 KiB, sum 1641 KiB),test-edge-store.ps1.🤖 Generated with Claude Code