fix(bot): wizard creates DB session but does not publish Telegram topic or signup message #135

Closed
opened 2026-06-09 16:07:30 +03:00 by Toutsu · 1 comment
Owner

Симптом

После релиза v3.9.8 wizard /newsession сообщает ✅ Создано: 1 сессия, и сессия видна через list sessions, но в Telegram не появляется forum topic и schedule/signup message.

Evidence

Production DB после пользовательского повтора показывала новую сессию:

id: f5be283c-919f-45fc-a205-5e38e9be04f0
title: Тест
created_at: 2026-06-09 12:59:43 UTC
thread_id: NULL
batch_message_id: NULL
topic_created_by_bot: false
platform: Telegram
external_group_id: -1003916537960

Production bot/db logs после deploy не показывали 42883, то есть DB create уже был успешен.

Подтверждённый root cause

src/GmRelay.Bot/Features/Sessions/CreateSession/CreateSessionHandler.cs::SubmitDraftAsync после _shared.HandleAsync(cmd, ct) только редактировал wizard draft message на ✅ Создано: ... и удалял draft.

Он не вызывал:

  • IPlatformMessenger.CreateThreadAsync(...)
  • IPlatformMessenger.SendScheduleAsync(...)
  • UPDATE sessions SET thread_id, batch_message_id, topic_created_by_bot

Поэтому DB rows создавались, но Telegram publication side-effects отсутствовали.

Решение (3.9.9)

  1. После успешного shared create создать topic при необходимости.
  2. Отправить schedule/signup message.
  3. Сохранить thread_id, batch_message_id, topic_created_by_bot для всего batch.
  4. Не повторять DB create при publication failure, чтобы не создавать дубликаты.
  5. Добавить Testcontainers regression test на wizard submit happy path.
## Симптом После релиза `v3.9.8` wizard `/newsession` сообщает `✅ Создано: 1 сессия`, и сессия видна через list sessions, но в Telegram не появляется forum topic и schedule/signup message. ## Evidence Production DB после пользовательского повтора показывала новую сессию: ```text id: f5be283c-919f-45fc-a205-5e38e9be04f0 title: Тест created_at: 2026-06-09 12:59:43 UTC thread_id: NULL batch_message_id: NULL topic_created_by_bot: false platform: Telegram external_group_id: -1003916537960 ``` Production bot/db logs после deploy не показывали `42883`, то есть DB create уже был успешен. ## Подтверждённый root cause `src/GmRelay.Bot/Features/Sessions/CreateSession/CreateSessionHandler.cs::SubmitDraftAsync` после `_shared.HandleAsync(cmd, ct)` только редактировал wizard draft message на `✅ Создано: ...` и удалял draft. Он не вызывал: - `IPlatformMessenger.CreateThreadAsync(...)` - `IPlatformMessenger.SendScheduleAsync(...)` - `UPDATE sessions SET thread_id, batch_message_id, topic_created_by_bot` Поэтому DB rows создавались, но Telegram publication side-effects отсутствовали. ## Решение (3.9.9) 1. После успешного shared create создать topic при необходимости. 2. Отправить schedule/signup message. 3. Сохранить `thread_id`, `batch_message_id`, `topic_created_by_bot` для всего batch. 4. Не повторять DB create при publication failure, чтобы не создавать дубликаты. 5. Добавить Testcontainers regression test на wizard submit happy path.
Author
Owner

Реализовано в PR #137 и выпущено в v3.9.9.

Root cause: SubmitDraftAsync создавал DB rows через shared handler, но не выполнял Telegram publication side-effects (CreateThreadAsync, SendScheduleAsync) и не сохранял thread_id/batch_message_id.

Реализовано в PR #137 и выпущено в v3.9.9. - PR: https://git.codeanddice.ru/Toutsu/GmRelayBot/pulls/137 - Release: https://git.codeanddice.ru/Toutsu/GmRelayBot/releases/tag/v3.9.9 - Merge commit: `bbd58142dbc3179137ca6b7864270b97f3054d98` - PR checks: run #315 — success - Deploy: run #316 — success Root cause: `SubmitDraftAsync` создавал DB rows через shared handler, но не выполнял Telegram publication side-effects (`CreateThreadAsync`, `SendScheduleAsync`) и не сохранял `thread_id`/`batch_message_id`.
Toutsu added reference 2026-06-09 16:55:38 +03:00
Toutsu added reference 2026-06-09 16:56:06 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Toutsu/GmRelayBot#135