Skip to content

{channels, docs}: implement tenant-scoped Telegram long polling adapter - #32

Merged
XnLemon merged 6 commits into
mainfrom
codex/31-telegram-long-polling
Aug 23, 2026
Merged

{channels, docs}: implement tenant-scoped Telegram long polling adapter#32
XnLemon merged 6 commits into
mainfrom
codex/31-telegram-long-polling

Conversation

@XnLemon

@XnLemon XnLemon commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Fixes #31

Outcome

Implements a tenant-scoped Telegram long-polling Channel Adapter while preserving the existing trusted Binding and Gateway boundaries.

Docs-first delivery

  • Documentation contract was published first in commit 4a3cd13.
  • Runtime implementation landed in 47f6039; coverage/lint and review-closure commits are 81f5f1f, 54fe7dd, 850d4e1, and 5b35e1a.
  • The implementation status is recorded in README.md and docs/docs/telegram.md.

Scope delivered

  • Pins github.com/go-telegram/bot at v1.23.0.
  • Adds trpcservice/channels/telegram with injectable Bot factory/client, runtime-only token handling, optional HTTPS API origin/HTTP client/poll timeout, worker count, redacted error hook, blocking Run(ctx), and Close.
  • Accepts exactly one trusted active Telegram RoutingTarget; verifies getMe bot identity against canonical provider_account_id before handling updates.
  • Maps ordinary private/group/supergroup text updates through gateway.NewChannelPrincipal, InboundMessage.Normalize, and the existing gateway.DispatchService.
  • Uses Binding-aware stable external/request IDs and the existing process-local gateway.IdempotencyStore; pending duplicates do not dispatch and completed duplicates replay cached redacted events.
  • Drains the complete Dispatch event stream, aggregates one logical text reply, splits at 4096 Unicode code points, preserves forum thread IDs, and uses a fixed redacted failure reply.
  • Rejects edited/channel/callback/inline/command/service/media/non-text/malformed updates without dispatch; webhook, rich media, persistent outbox/idempotency, and cross-node ownership remain out of scope.
  • Preserves caller cancellation during in-flight getMe and does not emit a misleading initialization hook for shutdown/deadline cancellation.
  • Adds fake Bot/Factory and Gateway tests covering identity, isolation, mapping, event draining, Unicode chunking, duplicate delivery, commands, unsupported updates, redaction, getMe cancellation, polling hooks, and lifecycle.

Validation

  • go test ./... -count=1
  • go test -race ./... -count=1
  • go vet ./...
  • go build ./...
  • python -m mkdocs build --strict -f docs\mkdocs.yml
  • bash ./scripts/lint.sh
  • gofmt changed Telegram files
  • git diff --check
  • Remote CI: Format & Lint, Build/Test/Coverage, MkDocs, and Codecov patch all pass on final head 5b35e1a.

Local Telegram package coverage is 90.8%; Codecov patch coverage is above the repository's 85% gate.
lint.sh skipped golangci-lint locally because it is not installed; the remote Format & Lint check passed.

Review notes

  • Docs-stage review: LGTM on 4a3cd13.
  • Final implementation review: two valid findings were fixed in 5b35e1a, then the fresh exact-head review found no remaining issues and posted fallback LGTM.
  • The branch preserves unrelated pre-existing untracked workspace files. No merge is requested by this PR.

@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.56383% with 43 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
trpcservice/channels/telegram/telegram.go 88.56% 27 Missing and 16 partials ⚠️

📢 Thoughts on this report? Let us know!

@XnLemon XnLemon left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@XnLemon XnLemon self-assigned this Aug 23, 2026
Comment thread trpcservice/channels/telegram/telegram.go
Comment thread trpcservice/channels/telegram/telegram.go
@XnLemon

XnLemon commented Aug 23, 2026

Copy link
Copy Markdown
Owner Author

LGTM

@XnLemon
XnLemon merged commit 896effe into main Aug 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

channel: implement tenant-scoped Telegram long-polling adapter

1 participant