Repository navigation
feat(integrations): github and slack, plus Linear-quality PR notifications - #36
Conversation
…tions GitHub connects on webhooks: link a repository, verify and receive events, map pull requests and their reviews to issues, and show the linked PR state on the issue. Slack connects a channel, unfurls issue links and posts notifications. Both verify their webhook signatures, GitHub by HMAC and Slack by its signing secret. The notification taxonomy now carries the PR events that actually matter, the ones the product owner called out: review requested, review submitted, approved, merged and checks failed, alongside the existing issue, comment and mention events, grouped and filterable like Linear's inbox. A PRs section surfaces the pull requests linked to a person's work with their review state. Everything realtime.
# Conflicts: # apps/web/src/features/inbox/inbox-view.tsx
…nded streams Add a git_link loader to the reconnect backfill so catchup covers the new sync model, restore the integration:manage permission the policy merge dropped, and keep S4's fine-grained inbox patching while preserving the mentions and pull request tabs.
📝 WalkthroughWalkthroughThis PR adds GitHub pull-request synchronization and notifications, Slack integration management and unfurl handling, a pull-request viewing experience, and inbox filtering with separate mention unread counts. ChangesGitHub pull requests
Slack and integration management
Inbox notification filtering
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 17
🧹 Nitpick comments (7)
packages/services/src/github/github.test.ts (1)
99-143: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMissing test coverage for
check_suiteevent normalization.
parseGithubEventhandles three event types but this suite only exercisespull_requestandpull_request_review.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/services/src/github/github.test.ts` around lines 99 - 143, The parseGithubEvent test suite lacks coverage for check_suite normalization. Add a test in the parseGithubEvent describe block that supplies a representative check_suite payload and asserts the normalized check-suite event fields, while preserving the existing pull request, review, and unrelated-event tests.packages/services/src/github/index.ts (1)
85-85: 📐 Maintainability & Code Quality | 🔵 TrivialUse top-level
z.url()instead of the deprecated.string().url()chain.Zod 4 deprecated the chained string-format methods in favor of top-level functions; the chained form still works but will be removed in a future major version.
♻️ Proposed fix
- html_url: z.string().url().max(2048), + html_url: z.url().max(2048),Apply similarly at line 111 (
review.html_url).Also applies to: 111-111
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/services/src/github/index.ts` at line 85, Update the `html_url` and `review.html_url` schema definitions to use top-level `z.url()` with the existing maximum-length constraint, removing the deprecated `z.string().url()` chain while preserving URL validation and the 2048-character limit.packages/services/src/github/apply.test.ts (2)
232-236: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winFragile assumption: destructured
eventmay not be the assertedpr_approvedevent.Line 232 checks
.some(...)forpr_approved, but line 233 destructures the first array element and asserts itsuserIdswithout confirming it's the same event. If a future change adds another notification event alongsidepr_approved(e.g., a genericpr_review_submitted), this test could silently assert against the wrong event.🧪 Proposed fix
- expect(result.notificationEvents.some((event) => event.type === 'pr_approved')).toBe(true); - const [event] = result.notificationEvents; + const event = result.notificationEvents.find((e) => e.type === 'pr_approved'); + expect(event).toBeDefined(); expect(event?.userIds).toContain(fixture.creatorId); expect(event?.userIds).toContain(fixture.assigneeId);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/services/src/github/apply.test.ts` around lines 232 - 236, Update the test around the notificationEvents assertions to select the event whose type is pr_approved before validating userIds, rather than destructuring the first event. Keep the existing checks for fixture.creatorId and fixture.assigneeId on that specifically selected approval event.
212-263: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate
pull_request_reviewpayload construction across two tests.The review-event body built for "approved" (lines 215-230) and "changes_requested" (lines 242-257) is nearly identical, differing only in
review.state/user. Consider a small helper mirroringprEvent()to reduce duplication and ease future maintenance.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/services/src/github/apply.test.ts` around lines 212 - 263, Extract the shared pull_request_review payload construction from the two tests into a small helper, mirroring the existing prEvent() pattern. Parameterize the differing review state and user data, then use the helper in both approval and changes_requested test cases while preserving their existing assertions and event behavior.apps/web/src/app/api/integrations/github/route.ts (1)
98-133: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueOptional: reduce round-trips in
ensureIntegration.The fresh-connect path does select → insert → select. Using
.onConflictDoNothing().returning()and only falling back to a select when the returned array is empty would save one query on first connect.♻️ Proposed refactor
if (existing !== undefined) return existing.id; const id = randomUUIDv7(); - await db + const [inserted] = await db .insert(schema.integration) .values({ id, organizationId, provider: 'github', externalId, connectedById }) - .onConflictDoNothing(); - const [row] = await db - .select({ id: schema.integration.id }) - .from(schema.integration) - .where( - and( - eq(schema.integration.organizationId, organizationId), - eq(schema.integration.provider, 'github'), - eq(schema.integration.externalId, externalId), - ), - ) - .limit(1); - return row?.id ?? id; + .onConflictDoNothing() + .returning({ id: schema.integration.id }); + if (inserted !== undefined) return inserted.id; + const [row] = await db + .select({ id: schema.integration.id }) + .from(schema.integration) + .where( + and( + eq(schema.integration.organizationId, organizationId), + eq(schema.integration.provider, 'github'), + eq(schema.integration.externalId, externalId), + ), + ) + .limit(1); + return row?.id ?? id;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/app/api/integrations/github/route.ts` around lines 98 - 133, Optimize ensureIntegration by making the insert return the created integration ID via onConflictDoNothing().returning(), then return that ID immediately when insertion succeeds. Only perform the existing lookup after an empty returning result, preserving the existing-ID path and conflict behavior.packages/services/src/slack/dispatch.test.ts (1)
63-71: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider adding coverage for
ensureSlackIntegrationandresolveSlackContext's failure paths.Only the "happy path" read of
resolveSlackContextis tested. Given the correctness concerns raised indispatch.tsaroundexternalIdscoping and defaults, tests forensureSlackIntegration's upsert behavior andresolveSlackContextreturningnull/token: nullfor missing or malformed credentials would help lock down intended behavior.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/services/src/slack/dispatch.test.ts` around lines 63 - 71, Add tests in the existing Slack dispatch test suite covering ensureSlackIntegration upsert behavior, including externalId scoping, and resolveSlackContext failure cases. Verify missing credentials return null and malformed credentials produce the expected token: null result, while preserving the existing happy-path coverage.packages/services/src/slack/dispatch.ts (1)
168-195: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winSequential per-item await loops for network/DB fan-out.
dispatchSlackMessageposts to each channel target one at a time, andresolveIssueUnfurlsloads each issue one at a time — both could be parallelized (e.g.,Promise.allSettled) to cut latency, especially sincedispatchSlackMessageis awaited inline in the GitHub webhook handler's request path before it responds.♻️ Example for dispatchSlackMessage
- let delivered = 0; - for (const target of targets) { - try { - await client.postMessage({ - channel: target.channelId, - text: input.text, - ...(input.blocks === undefined ? {} : { blocks: input.blocks }), - }); - delivered += 1; - } catch (error) { - console.error('[orbit] slack channel post failed', error); - } - } - return delivered; + const results = await Promise.allSettled( + targets.map((target) => + client.postMessage({ + channel: target.channelId, + text: input.text, + ...(input.blocks === undefined ? {} : { blocks: input.blocks }), + }), + ), + ); + results + .filter((result) => result.status === 'rejected') + .forEach((result) => console.error('[orbit] slack channel post failed', result.reason)); + return results.filter((result) => result.status === 'fulfilled').length;Also applies to: 239-253
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/services/src/slack/dispatch.ts` around lines 168 - 195, Parallelize the per-target network work in dispatchSlackMessage and the per-issue loads in resolveIssueUnfurls instead of awaiting each item sequentially. Use an all-settled pattern so one failure does not prevent other items from completing, preserve the existing error handling, and ensure dispatchSlackMessage still returns the count of successfully delivered messages.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/src/app/api/integrations/git-links/route.ts`:
- Line 6: Move the integration query schema currently declared as querySchema
into `@orbit/shared/validators`, export it there using the shared idSchema, and
update the route handler to import and use that shared schema for request
parsing instead of defining a local Zod schema.
- Around line 8-34: Update GET to enforce the shared issue-read policy after
parsing issueId and before querying schema.gitLink. Reuse the repository’s
established policy assertion for the specified issue, while preserving the
existing organization, issue, and pull-request filters.
In `@apps/web/src/app/api/integrations/github/route.ts`:
- Around line 35-96: Update POST and DELETE in
apps/web/src/app/api/integrations/github/route.ts (lines 35-96) and the
corresponding mutation handlers in
apps/web/src/app/api/integrations/slack/route.ts (lines 42-72) to use the shared
mutation pipeline or return SyncActions and publish them. Ensure every direct
mutation of githubRepositorySync, integration, and slackChannelSync bumps
sync_id and invokes publish so realtime subscribers receive repository and
channel mapping changes.
- Around line 41-77: Validate input.teamId belongs to principal.organizationId
before persisting it in the GitHub route’s ensureIntegration/repository mutation
and the Slack route’s corresponding channel mutation; reject cross-workspace
teams. Update both mutations to advance sync_id and publish the appropriate
SyncAction through the existing sync pipeline so realtime clients receive the
changes. Affected sites: apps/web/src/app/api/integrations/github/route.ts lines
41-77 and apps/web/src/app/api/integrations/slack/route.ts lines 57-67; apply
both validations and sync publications at each site.
In `@apps/web/src/app/api/integrations/slack/route.ts`:
- Around line 89-100: Update the Slack API call flow used by PATCH and
SlackClient.listConversations to enforce an AbortSignal timeout around the
underlying SlackClient.call fetch, ensuring stalled requests terminate; if
retries are added, bound their count and preserve the existing validation and
channel response behavior.
In `@apps/web/src/app/api/webhooks/github/route.ts`:
- Around line 26-46: The GitHub webhook deduplication flow must allow retries
for non-processed deliveries and mark failed attempts consistently. Update the
claim logic around the webhookDelivery insert to inspect an existing row’s
status and return “duplicate” only when it is “processed”; reuse or update the
matched delivery record for other statuses. Ensure every early-return failure
path in the handler, including the JSON.parse failure, updates that delivery row
to “failed” before responding.
- Around line 63-70: Update the Slack dispatch block in the webhook route to
build the inbox link through the shared public URL helper from env.ts, using
absoluteUrl or publicAppUrl instead of reading NEXT_PUBLIC_APP_URL or
concatenating a localhost fallback. Preserve the existing organization, team,
and message behavior while passing the helper-generated inbox URL in
outcome.slackText.
In `@apps/web/src/app/api/webhooks/slack/route.ts`:
- Around line 30-31: Update the Slack webhook route’s slackEventSchema usage so
request parsing relies on a Zod schema owned or re-exported by `@orbit/shared`
rather than `@orbit/services`. Relocate or re-export the schema through
`@orbit/shared`, then update the route import while preserving the existing
safeParse validation and response behavior.
In `@apps/web/src/features/inbox/inbox-view.tsx`:
- Around line 161-172: Update InboxView’s realtime patch and snooze/delete
response handling to carry and apply an unread-mention delta or count alongside
unread. Centralize counter reconciliation so every incoming, snoozed, and
deleted update modifies both unread and mentions, while preserving the existing
prop synchronization in the useEffect.
In `@apps/web/src/features/pulls/pulls-view.tsx`:
- Around line 36-43: The pull-list subscription and git-link backfill must use
the same personal pull-update scope contract. In
apps/web/src/features/pulls/pulls-view.tsx lines 36-43, subscribe to the scopes
used for personal pull updates rather than only scopes.user(userId). In
packages/core/src/realtime/backfill.ts lines 477-481, emit recipient user scopes
for the issue assignee and creator, and update the live publisher to use that
same contract.
- Around line 37-48: Replace the router.refresh flow in
apps/web/src/features/pulls/pulls-view.tsx#L37-L48 with a keyed TanStack Query
for the personal pull list, patching or invalidating that query from relevant
notification and git_link deltas without a full route refresh. In
apps/web/src/features/pulls/issue-pull-requests.tsx#L25-L51, replace local fetch
state with a keyed query that exposes request errors and updates the issue
pull-list cache from git_link actions; update both sites using the existing
query keys, fetchers, and shared realtime-cache utilities.
In `@apps/web/src/features/settings/integrations-panel.tsx`:
- Around line 20-32: Replace the raw apiRequest/router.refresh mutation flow in
IntegrationsPanel’s call function with TanStack Query mutations, using
optimistic cache updates for integration changes and invalidating or patching
affected query data without triggering a full router refresh. Preserve existing
error handling through setError and ensure link/unlink repository and Slack
install/connect/disconnect actions all use the shared mutation path.
In `@packages/services/src/github/apply.ts`:
- Around line 158-229: Determine whether the upsert inserted or updated the row
using the database result, not the pre-fetch result in existing. Update the
gitLink insert/upsert return path and buildAction call to expose and use an
insertion indicator, such as a PostgreSQL xmax-based RETURNING expression, so
concurrent deliveries emit exactly one insert action and update actions for
conflicts. Preserve the existing lookup for row identity and state handling.
- Around line 83-94: Update the issue-resolution flow around identifiers and
loadLinkedIssues to also resolve check_suite events through existing gitLink
rows using checks.prNumbers, matching provider GitHub, repository, and PR
number; merge or prefer these linked issues alongside text-extracted identifiers
so already-linked PRs work when branch/title parsing yields none. Preserve the
current identifier-based lookup for events without matching git links.
- Around line 306-355: Gate the review-decision branch in
pullRequestNotification on the appropriate review submission action, so edited
pull_request_review events do not emit repeated pr_approved or
pr_review_submitted notifications. Preserve the existing review decision and
dismissal checks for qualifying review actions, while leaving the
review_requested and lifecycle branches unchanged.
In `@packages/services/src/slack/dispatch.ts`:
- Around line 67-124: Update connectSlackChannel and disconnectSlackChannel to
participate in the existing sync pipeline: bump the relevant syncId and publish
the corresponding SyncAction after their slackChannelSync mutations, matching
the behavior of other mutators in this codebase. If these rows are intentionally
excluded from realtime updates, document that contract instead.
- Around line 24-36: Update resolveSlackContext in
packages/services/src/slack/dispatch.ts to accept a Slack workspace/team id and
add an integration.externalId filter alongside the existing organization and
provider filters. Update the caller in
apps/web/src/app/api/webhooks/slack/route.ts to pass slackTeamId, and apply the
same argument wherever another caller already knows the workspace id.
---
Nitpick comments:
In `@apps/web/src/app/api/integrations/github/route.ts`:
- Around line 98-133: Optimize ensureIntegration by making the insert return the
created integration ID via onConflictDoNothing().returning(), then return that
ID immediately when insertion succeeds. Only perform the existing lookup after
an empty returning result, preserving the existing-ID path and conflict
behavior.
In `@packages/services/src/github/apply.test.ts`:
- Around line 232-236: Update the test around the notificationEvents assertions
to select the event whose type is pr_approved before validating userIds, rather
than destructuring the first event. Keep the existing checks for
fixture.creatorId and fixture.assigneeId on that specifically selected approval
event.
- Around line 212-263: Extract the shared pull_request_review payload
construction from the two tests into a small helper, mirroring the existing
prEvent() pattern. Parameterize the differing review state and user data, then
use the helper in both approval and changes_requested test cases while
preserving their existing assertions and event behavior.
In `@packages/services/src/github/github.test.ts`:
- Around line 99-143: The parseGithubEvent test suite lacks coverage for
check_suite normalization. Add a test in the parseGithubEvent describe block
that supplies a representative check_suite payload and asserts the normalized
check-suite event fields, while preserving the existing pull request, review,
and unrelated-event tests.
In `@packages/services/src/github/index.ts`:
- Line 85: Update the `html_url` and `review.html_url` schema definitions to use
top-level `z.url()` with the existing maximum-length constraint, removing the
deprecated `z.string().url()` chain while preserving URL validation and the
2048-character limit.
In `@packages/services/src/slack/dispatch.test.ts`:
- Around line 63-71: Add tests in the existing Slack dispatch test suite
covering ensureSlackIntegration upsert behavior, including externalId scoping,
and resolveSlackContext failure cases. Verify missing credentials return null
and malformed credentials produce the expected token: null result, while
preserving the existing happy-path coverage.
In `@packages/services/src/slack/dispatch.ts`:
- Around line 168-195: Parallelize the per-target network work in
dispatchSlackMessage and the per-issue loads in resolveIssueUnfurls instead of
awaiting each item sequentially. Use an all-settled pattern so one failure does
not prevent other items from completing, preserve the existing error handling,
and ensure dispatchSlackMessage still returns the count of successfully
delivered messages.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2d9fae1c-d928-4f59-8cde-fc17eac9c937
📒 Files selected for processing (39)
apps/web/src/app/(app)/inbox/page.tsxapps/web/src/app/(app)/pulls/page.tsxapps/web/src/app/(app)/settings/integrations/page.tsxapps/web/src/app/api/integrations/git-links/route.tsapps/web/src/app/api/integrations/github/route.tsapps/web/src/app/api/integrations/slack/route.tsapps/web/src/app/api/webhooks/github/route.tsapps/web/src/app/api/webhooks/slack/route.tsapps/web/src/components/keyboard-hints.test.tsxapps/web/src/features/inbox/data.tsapps/web/src/features/inbox/inbox-realtime.tsxapps/web/src/features/inbox/inbox-view.tsxapps/web/src/features/issues/issue-detail.tsxapps/web/src/features/pulls/data.tsapps/web/src/features/pulls/issue-pull-requests.tsxapps/web/src/features/pulls/pr-state.tsapps/web/src/features/pulls/pulls-realtime.tsxapps/web/src/features/pulls/pulls-view.tsxapps/web/src/features/settings/integrations-data.tsapps/web/src/features/settings/integrations-panel.tsxapps/web/src/features/settings/settings-nav.tsxapps/web/src/lib/navigation.tspackages/core/src/realtime/backfill.tspackages/services/src/github/apply.test.tspackages/services/src/github/apply.tspackages/services/src/github/github.test.tspackages/services/src/github/index.tspackages/services/src/index.tspackages/services/src/notifications/index.tspackages/services/src/notifications/notifications.test.tspackages/services/src/slack/dispatch.test.tspackages/services/src/slack/dispatch.tspackages/services/src/slack/index.tspackages/shared/src/constants/notification.tspackages/shared/src/events/sync.tspackages/shared/src/policy/index.tspackages/shared/src/policy/policy.test.tspackages/shared/src/validators/index.tspackages/shared/src/validators/integration.ts
Use safeParse in parseGithubEvent so a malformed payload returns an empty result instead of aborting the webhook transaction and dropping the delivery. Derive git_link insert vs update from the upsert RETURNING xmax so concurrent deliveries never broadcast a duplicate insert. Resolve check_suite issues via existing git_link rows keyed by PR number when branch names do not encode the identifier. Gate review-decision notifications on the submitted action so edited reviews do not renotify. Publish and backfill git_link actions to the issue creator and assignee user scopes so the personal pull list stays live.
…nt schema Filter resolveSlackContext on the integration externalId so a webhook that already knows the Slack team id cannot pick up another workspace's bot token. Add an AbortSignal timeout to every SlackClient call so a stalled Slack request cannot hang the handler. Move the Slack event schema into @orbit/shared so the webhook route parses request input with a shared validator.
… links Reprocess GitHub deliveries whose prior attempt did not reach processed, and mark every early-return path failed, so a redelivery of a failed or incomplete delivery is no longer dropped as a duplicate. Build the Slack inbox link with absoluteUrl instead of a localhost fallback. Assert issue:read on the git-links route and parse its query with a shared schema. Reject repository and channel links to a team outside the caller's workspace.
Give both integration Team selects an id and htmlFor so the label focuses the control. Carry a mention delta through the realtime patch and the local delete so the @ badge reflects incoming, read and deleted unread mentions without a reload.
…atches the client
Add GitHub and Slack integrations with webhooks, surface pull requests on issues and in an inbox, and send review-requested and approved notifications.
Greptile Summary
This PR adds GitHub and Slack integrations: a webhook handler that applies PR events to issues (state transitions, git links, notifications), a Slack dispatch layer for channel notifications and issue unfurls, an inbox overhaul with tab filtering and a mention badge, and a new Pull Requests view scoped to the current user's issues.
apps/web/src/app/api/webhooks/github/route.ts): verifies HMAC signatures, deduplicates deliveries byX-GitHub-Delivery, applies events inside a transaction, then publishes realtime actions and dispatches Slack notifications outside the transaction.packages/services/src/slack/dispatch.ts,slack/index.ts): stores a bot token in credentials, resolves per-team channel targets, posts PR notifications, and unfurls Orbit issue links shared in Slack.inbox-view.tsx,pulls-view.tsx): addsAll / Unread / Mentions / Pull requeststabs, a separate@mention badge, and a grouped PR list page with realtime refresh.Confidence Score: 3/5
The core GitHub event processing is solid and idempotent, but the webhook handler has a gap between transaction commit and delivery acknowledgement that can cause duplicate notifications on retry, and the Slack bot token sits unencrypted in the database.
Two independent gaps lower confidence. First, after the transaction commits notifications to the DB, any exception in the post-transaction Slack or Redis path marks the delivery failed. GitHub's next retry resets the delivery to received and re-runs notifyMany in a new transaction, producing duplicate inbox items for the same PR event. Second, the Slack bot token is stored as plaintext JSON in the credentials column — DB read access, backups, or slow-query logs expose it with no additional protection needed. Both issues are on paths that will be exercised in production the moment GitHub or Redis has a transient error.
apps/web/src/app/api/webhooks/github/route.ts (transaction commit vs. processed status gap) and packages/services/src/slack/dispatch.ts (plaintext bot token in ensureSlackIntegration).
Security Review
packages/services/src/slack/dispatch.ts—ensureSlackIntegration): the Slack bot token is written as{ botToken }in theintegration.credentialsJSON column with no encryption. DB read access, backups, or query logs expose the token directly. A server-side encryption layer (encrypt on write, decrypt on read inresolveSlackContext) would contain the blast radius to processes holding the key.timingSafeEqualand rejects an absent or empty secret — no bypass path identified.verifySlackSignature) is pre-existing and unchanged.teamIdin the Slack connect flow is validated against the caller's organization viaassertTeamInWorkspacebeforeconnectSlackChannelis called.integration:managepermission viaassertCan.Important Files Changed
Sequence Diagram
sequenceDiagram participant GH as GitHub participant WH as Webhook Handler participant DB as Postgres (tx) participant Redis participant Slack GH->>WH: POST /api/webhooks/github (X-GitHub-Delivery) WH->>WH: verifyGithubSignature WH->>DB: INSERT webhookDelivery (claimed) alt duplicate delivery WH-->>GH: 200 duplicate end WH->>DB: BEGIN TRANSACTION DB->>DB: applyGithubEvent (upsert gitLink, transition issue) DB->>DB: notifyMany (insert notifications) DB->>WH: COMMIT — actions + notificationEvents WH->>Redis: publish SyncActions WH->>DB: resolveSlackContext / resolveSlackTargets WH->>Slack: postMessage (PR update text) note over WH,Slack: If Slack/Redis throws here, delivery stays "received" → GH retry re-runs notifyMany WH->>DB: "UPDATE webhookDelivery SET status=processed" WH-->>GH: 200 okComments Outside Diff (1)
packages/services/src/slack/dispatch.ts, line 1453-1463 (link)credentialsin plaintextensureSlackIntegrationstores{ botToken: input.botToken }as plain JSON in theintegration.credentialscolumn. Any user or process with read access to theintegrationtable can retrieve the token directly. If DB backups or logs capture this column, the token is leaked. The token arrives from the browser over HTTPS, but at rest it is unprotected.Encrypting the value with a server-side key before writing (and decrypting on read in
resolveSlackContext) would limit exposure to processes that hold the encryption key rather than anyone who can read the table.Prompt To Fix With AI
Prompt To Fix All With AI
Reviews (4): Last reviewed commit: "fix(notifications): count mentions in th..." | Re-trigger Greptile