feat(github): deliver issue and PR alerts to linked topics (4/5) - #15
Merged
Merged
Conversation
Maps pull_request (opened, closed/merged, review_requested) and issues (opened, closed) payloads to allowlisted GithubEvent fields and routes them through org claim, team and repo link to the linked forum topic via sendMessage with message_thread_id. Unsupported events, unclaimed orgs and unlinked repos are acknowledged and logged; Telegram send failures return 2xx with a fixed failure class (rate-limited, telegram-unavailable, rejected); D1 failures return 500.
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.
Summary
Fourth PR of the
github-alertschain. This is where alerts actually reach Telegram./github/webhooknow maps the verified event, routes it through the org claim, the team and the repo link, and sends it to the linked forum topic.mapGithubEvent: reads only allowlisted fields (repo, action, GitHub login, number, title, link, reviewer). Commit author emails and names never leave the payload. Supported events:pull_request: opened, closed (ormergedwhenmerged === true), review_requested (reviewer login or team slug)issues: opened, closedcreateTelegramAlertSender:sendMessagewithmessage_thread_id, in plain text with noparse_mode, so PR titles cannot inject formatting.buildGithubRouterin the composition root: wires the D1 claim, link and team repos and the sender.Status policy (after a valid signature)
ignored:unsupported-eventAlertSendFailedwith a fixed class:rate-limited(429),telegram-unavailable(5xx or network),rejected(other 4xx). No retry in the request.Size exception: about 1,120 lines. Production code is about 260 of them; the rest is tests and apply-progress notes.
Review
Full review with four lenses: payload handling, PII, cross-team delivery. The first run was cut short by a rate limit and was re-run in full. No blocker or critical findings; the risk lens found nothing. Six warnings were fixed in one correction:
sendMessagecall ("no retry within the same request").test/support/telegram-stub.ts. It was copied in three files.A scoped fix-delta validator approved the correction.
Test plan
npx vitest run: 320/320 passnpx tsc --noEmit: no errorsAfter merge
GITHUB_WEBHOOK_SECRET. It is still pending: the route answers 500 until it is set.application/json, the same secret, and the Pull requests and Issues events. Check that the ping returns 200./linkrepo).