Skip to content

fix(bot): only post review and log entries to channels of the form's guild - #312

Merged
Musiker15 merged 1 commit into
mainfrom
fix/bot-channel-guild-scope
Nov 5, 2026
Merged

Musiker15 merged 1 commit into
mainfrom
fix/bot-channel-guild-scope

Conversation

@Musiker15

@Musiker15 Musiker15 commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Description

The bot now checks that the review channel and the log channel belong to the guild a notification is for. If the fetched channel is on another server (or is a DM), the delivery is dropped with a warning instead of being posted.

Channel ids in Form.settings.reviewChannelId and in the guild bot config are only validated as snowflakes when saved. client.channels.fetch resolves any channel the bot can see, on any server it was invited to. So a per-form manager could set the review channel to a channel on a server of their own, invite the bot there, and receive applicant names plus the answer preview of every new submission.

This came up in a real case: a form manager pointed a form's review channel at a channel outside the guild and invited the bot to that server minutes later. No data left the guild because the form had no submissions, but nothing in the code prevented it.

Changes:

  • apps/bot/src/channel-scope.ts: pure isChannelInGuild(channel, discordGuildId) helper
  • apps/bot/src/notifications.ts: deliverReview and deliverLog load the guild's discordGuildId and drop deliveries to foreign channels
  • apps/bot/src/channel-scope.test.ts: tests for own guild, foreign guild, DMs and a missing guild id
  • docs/features.md: one line noting that review and log channels must be on the guild's own server

Already scoped before this PR: the Accept/Reject buttons (review-actions.ts compares interaction.guildId), /forms post (fetches through interaction.guild.channels) and role grants (client.guilds.fetch(discordGuildId)).

Type of change

  • Bugfix
  • New feature
  • Breaking change
  • Refactor / tech debt
  • Docs / CI

Checklist

  • pnpm lint, pnpm typecheck, pnpm build pass locally (bot package: lint, typecheck, tests; the rest is left to CI)
  • Tests added/updated (where it makes sense). Counter-check: with the helper returning true, the foreign guild and DM tests fail
  • Prisma migration included (if the schema changed), not needed
  • No secrets / .env values committed
  • Security implications considered (input validation, authz, CSP)
  • Docs updated if architecture is affected

Linked issues

None

…guild

Channel ids in form settings and the guild bot config are only validated as
snowflakes, and client.channels.fetch resolves any channel the bot can see on
any server. A form manager could set the review channel to a channel on a
server of their own and receive the applicants' names and answer previews
there.

The bot now drops a review or log delivery when the fetched channel does not
belong to the guild the notification is for. The Accept/Reject buttons were
already scoped to the guild.
@graphify-labs

graphify-labs Bot commented Nov 5, 2026

Copy link
Copy Markdown

Graphify reviews are paused for this workspace because nobody has used it in 7 days. A workspace owner can resume reviews from the Repositories page: https://app.graphify.com/msk-scripts/repositories

@Musiker15
Musiker15 merged commit a04018b into main Nov 5, 2026
4 checks passed
@Musiker15
Musiker15 deleted the fix/bot-channel-guild-scope branch November 5, 2026 15:18
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.

1 participant