18 Commits

Author SHA1 Message Date
tiennm99 ea1005c2e8 fix(mongo): restore redis parity safeguards 2026-06-27 16:05:32 +07:00
tiennm99 c08317f79b test(mongo): use mongodb 8 container 2026-06-27 15:25:04 +07:00
tiennm99 70ecf12498 refactor(telegram): use go-telegram-bot runtime 2026-06-26 17:33:23 +07:00
tiennm99 b3ab6317fe fix(health): report readiness instead of static 200
The health endpoint returned 200 unconditionally from before dependencies were ready and never reflected MongoDB state. Handler now takes a readiness check; the endpoint returns 503 while starting or when MongoDB is unreachable and 200 only when ready.
2026-06-26 15:48:35 +07:00
tiennm99 c119386073 fix(bot): truncate messages on HTML-safe boundaries
Fixed-index truncation could split an HTML tag or entity or drop a closing tag, making Telegram reject the whole message with 'can't parse entities'. Cut on a newline boundary where tags are balanced, reserve room for a truncation notice, and strip any trailing partial markup.
2026-06-26 15:48:34 +07:00
tiennm99 30c8efc504 fix(poller): checkpoint each event independently after fan-out
A single retryable delivery failure aborted checkpoints for the whole poll batch, so fully-delivered events were re-collected and re-sent on the next poll, and an unrelated failure froze all change detection. Attach post-delivery checkpoints to each event and run them as soon as that event fully delivers; a failed event defers only its own checkpoints for retry. A subscriber skipped after an earlier retryable failure now counts as the event's failure so the event is not marked delivered to a subscriber that never received it.
2026-06-26 15:48:34 +07:00
tiennm99 0e7967feb6 fix(telegram): redact bot token from transport error messages
Transport-level failures return *url.Error embedding the full request URL, which contains the bot token. Strip the token before the error propagates to logs.
2026-06-26 14:01:28 +07:00
tiennm99 546e6fcde2 refactor(store): replace Redis with MongoDB datastore
Swap the Redis datastore for MongoDB via mongo-driver v2. New
internal/mongostore mirrors the old redisstore type/constant names so
consumers change only the import qualifier; document model collapses the
multi-key subscriber/settings and per-event delivery sets into single-doc
operations and a TTL-indexed delivery collection.

Config now requires MONGODB_URI (Atlas) with MONGODB_DATABASE selecting
dev vs prod on one cluster; REDIS_URL removed. Compose files run bot-only
against Atlas. Default tests stay Docker-free (poller/bot use fakes,
mongostore unit tests are pure-logic); a gated //go:build integration
suite covers the real backend via testcontainers.
2026-06-26 13:41:16 +07:00
tiennm99 90eb8fa819 Merge pull request #2 from tiennm99/refactor/batch-delivery-and-dedup-helpers
refactor(poller): batch delivery checks and dedupe component helpers
2026-06-26 09:21:19 +07:00
tiennm99 5f26bf4b15 refactor(poller): batch delivery checks and dedupe component helpers
Replace the per-subscriber SISMEMBER delivery check with a single
SMEMBERS per event plus in-memory lookups, cutting N round-trips to one.

Remove the component-label helpers duplicated between poller and bot by
exporting the canonical versions from poller; bot already depends on it.
Collapse the repeated component checkpoint closures into a shared helper.

Drop the redundant escapeAttr alias and the unused variadic on bot.New.
2026-06-26 09:19:29 +07:00
tiennm99 08b99ad68b perf(redisstore): batch subscriber settings into single HGETALL
ListSubscribers fetched settings with one HGET per subscriber. Replace
the per-key fetch with a single HGETALL and resolve each subscriber from
an in-memory map, cutting N round-trips to one per delivery cycle.

Extract resolveSubscriberSettings so the batched and single-key paths
share identical decode/default/self-heal behavior.
2026-06-26 09:04:12 +07:00
tiennm99 9f5a594cf7 fix(deploy): harden health and status config 2026-06-22 14:16:15 +07:00
tiennm99 956b2a98b4 feat(bot): register telegram command menu 2026-06-22 10:15:50 +07:00
tiennm99 204a76a32d feat(config): use REDIS_URL for redis 2026-06-22 09:19:25 +07:00
tiennm99 f022e8463c fix: harden status delivery and state recovery 2026-06-20 22:12:04 +07:00
tiennm99 e10fe0c883 fix: address status bot reliability issues 2026-06-19 16:52:41 +07:00
tiennm99 2a4519106e fix: align status bot delivery behavior 2026-06-19 15:56:59 +07:00
tiennm99 87f091beb8 feat: scaffold openai status bot 2026-06-19 14:39:19 +07:00