feat(portal): one-click Telegram allowlist from recent senders#58
Merged
Conversation
The Telegram editor's allowlist was manual numeric-id entry. Now a 'Load recent senders' button peeks at getUpdates and lists whoever recently messaged the bot; click a name to add its id to allowed_senders. Peek uses timeout=0 and NO offset, so it only reads and never acknowledges/drops updates for a running poller. It can't run concurrently with 'channels start' (Telegram allows one getUpdates consumer) -> that surfaces as a clear 409 'stop channels start / add IDs by hand' message. Token stays in the URL path, never logged. Backend telegram_recent_senders() + GET /api/telegram/senders; 5 new tests (parse/dedup/409/empty/route + static guard). Full suite 490 pass/1 skip. Playwright: button renders + click path handled (dead-token error state). Adversarial (Explore subagent): VERDICT CLEAN.
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.
What & why
Telegram 编辑器的白名单之前只能手敲数字 ID。现在加了 「Load recent senders」:一键 peek
getUpdates,列出最近给 bot 发过消息的人(名字 +@username+ id),点一下就加进allowed_senders。setup 时你给 bot 发条消息,portal 一键拉到你的 id 加白名单,不用去@userinfobot查。telegram_recent_senders()+GET /api/telegram/senders。addTgSender(点选加到#tgsenderstextarea)。关键设计:与
channels start的关系Telegram 同一时刻只允许一个
getUpdates消费者,所以这个功能主要用于 setup 阶段(channels start停着时)。peek 用timeout=0且 不传offset—— 纯只读,绝不 ack / 推进 offset,不会让正在跑的 poller 丢消息。若start正在跑 → 409 → 清晰提示「先停channels start,或手填 ID」。token 只在 URL path,从不记日志。Testing
ruffclean;全套件 490 pass / 1 skip(3 个 pre-existing Windows-only fail 与本 PR 无关)。🤖 对抗评审
Reviewer: Claude
general-purposesubagent(此机无 Codex),read-only,一轮。VERDICT: CLEAN:offset+timeout=0,只读不 ack,不会让 running poller 丢消息;并发只导致一方 409(双方都正确处理)。result非 list →[];畸形 /edited_message/ 缺from/ 非 intid全跳过;去重正确;name非空、usernamestr|None、chat_typestr|None,无 KeyError/TypeError。addTgSender用后端校验过的数字 id 字符串;guardcurrent()/#tgrecent/token_resolvable;单编辑器无 DOM id 冲突。limit:100封顶,dedup dict ≤100,httpx timeout 15s。无
RISK,无需 fix/rebut。