Repository navigation
fix(scheduler): deliver portal-chat reminders to the owner's Telegram DM - #164
Merged
Merged
Conversation
… DM (#163) Portal web-chat turns have a non-numeric chat_id, so reminders they created could never be sent. Scheduling tools now scope such turns to the shim bot and its first allowed user, for create, list, cancel and history alike. Boot moves existing non-numeric-chat rows to that owner with a warn log. When Telegram refuses the DM because /start was never sent, the run is marked failed with a hint naming @username (or the bot id).
Owner
Author
|
TL ACCEPT at Matches locked AC: web turns scoped to shim+owner for create/list/cancel; Merge after Product GO + QA GO (incl. live AC1) + CI ( |
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.
Closes #163
Root cause
Portal web chat builds its turn with
chat_id = user_id = "web"on botdefault.schedule_taskstored those values, and at fire time the runner failedchat_id.parse::<i64>()("Unparseable chat_id"), so nothing was sent.Fix
SchedulingTools::with_telegram_owner(shim bot id, first allowed user id), wired inmain.rsfromConfig::shim_bot. Any turn whosechat_idis not numeric is scoped to that bot and owner DM before the tool runs, so create, list, cancel, history and reruns all see the same rows. Telegram turns are unchanged.adopt_web_schedules: existing rows with a non-numericchat_idmove to the shim bot owner DM, with a warn log of the count. Idempotent.telegram::not_started_hint: when the final send is refused, the run is markedfailedwith a hint, plus a warn log. Three cases get separate text:bot can't initiate conversation(403):Not delivered: open Telegram and send /start to @<username>bot was blocked by the user(403):Not delivered: you blocked @<username> in Telegram; unblock it to get reminderschat not found(400):Not delivered: Telegram can't find this chat; check the user id in allowed_user_ids, then send /start to @<username>@<username>comes fromgetMe, called only on this failure path; it falls back tothe '<id>' bot.failedand the error text, so no UI change.Tests
web_turn_schedules_on_owner_dm_and_can_list_and_cancel: web turn row lands onmain/owner, web list and cancel find it; a Telegram turn keeps its own bot and chat.adopt_web_schedules_moves_non_numeric_chats_to_owner:webrows move, DM and negative group ids stay, second run is a no-op, empty allowlist moves nothing.not_started_hint_only_for_unstarted_chats: one hint per error kind,Nonefor anything else.cargo fmt --check,cargo clippy --locked --all-targets -- -D warnings,cargo test --locked: 926 passed.QA matrix
chat_id=webrow is moved at boot with the warn log, then fires to Telegram./start, the portal run showsfailedwith the/starthint, plus a warn log. Optional: blocked bot shows the unblock hint; a wrong owner id shows the check-user-id hint.