Repository navigation
Conversation
Split TgWebhookHandler into three modules: - TgUpdateHandler: shared business logic - TgPollingHandler: thin polling wrapper for dev - TgHookHandler: thin webhook wrapper for production Handler selection is driven by :tg_mode config (:polling/:webhook/:disabled). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Code ReviewOverviewClean refactor that separates transport concerns (webhook vs. polling) from shared bot logic. The three-way IssuesBug / Crash Risk —
|
| Architecture | ✅ Clean separation of transport vs. business logic |
| Correctness | on_boot crash risk; optional webhook secret |
| Style | |
| Tests | ✅ Existing tests correctly updated; thin wrappers untested (low risk) |
| Security |
The two blocking items are the crash risk in on_boot and the optional webhook secret. Everything else is minor polish.
🤖 Generated with Claude Code
|
Could we integrate webhook into phoenix routes without separate port? |
- Replace Telegex.Hook.GenHandler with a GenServer that registers the webhook on boot + a Phoenix controller that receives updates - Require TG_WEBHOOK_SECRET in production (was silently optional) - Use `with` in webhook setup to handle API errors gracefully - Fix stale file path in AGENTS.md - Revert accidental dev port change (4003 → 4000) - Remove separate webhook port config (TG_WEBHOOK_PORT) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Extract secret-token check into BodhiWeb.Plugs.TelegramWebhookAuth and pipe the webhook scope through it instead of branching in the action - Drop Task.start from controller; the request process already handles the update synchronously - Derive webhook URL from BodhiWeb.Endpoint.url() + route path; remove TG_WEBHOOK_URL env var (TG_WEBHOOK_SECRET still required in prod) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Extend Bodhi.Behaviours.TelegramClient with delete_webhook/0 and set_webhook/2 so Bodhi.TgHookHandler goes through the same Bodhi.Telegram indirection as every other Telegram call, making webhook registration mockable with Bodhi.TelegramMock. Add tests for the previously-untested TgHookHandler, TgPollingHandler, TelegramWebhookAuth plug, and TelegramWebhookController, and document the polling/webhook handler split in AGENTS.md and the required TG_WEBHOOK_SECRET env var in README.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…down # Conflicts: # README.md
…tests
start_supervised/1 starts children under a Supervisor, so a permanent
child's init failure surfaces as {:error, {reason, child_spec}}, not
{:error, reason} directly. CI caught the mismatch since Postgres (and
therefore mix test) isn't available in this sandbox.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Summary
Bodhi.TgUpdateHandler, replacingBodhi.TgWebhookHandlerBodhi.TgPollingHandler(thin wrapper for dev/test) andBodhi.TgHookHandler(thin wrapper for production webhook mode)Bodhi.Applicationbased on:tg_modeconfig (:polling,:webhook, or:disabled)TG_WEBHOOK_URL,TG_WEBHOOK_SECRET,TG_WEBHOOK_PORTenv vars inruntime.exsTest plan
mix compile— no warningsmix test— 250 tests, 0 failuresmix format— cleanmix dialyzer— 0 errorsiex -S mix🤖 Generated with Claude Code