Skip to content

RM-254: Refactor permission checks for thread/channel modes - #134

Open
biast12 wants to merge 24 commits into
masterfrom
RM-254
Open

biast12 wants to merge 24 commits into
masterfrom
RM-254

Conversation

@biast12

@biast12 biast12 commented Apr 11, 2026 •

Copy link
Copy Markdown
Contributor

Description

Make permission checking mode-aware and group missing perms by location.

  • Adjust server-wide permission list to depend on settings.UseThreads to avoid reporting irrelevant missing permissions. Append standard permissions after mode-specific ones.
  • In panel permission checks, treat a panel as using threads if either global settings or the panel enable threads. Use logic.ThreadPermissions for thread-mode channel checks and simplify assembled permission slices.
  • Add ThreadPermissions constant in bot/logic/discordpermissions.go for reuse.
  • Rewrite findMissingPermissions to return labeled missing-permission groups (panel channel, notification channel, transcript channel) instead of a flat list; check primary channel, optional notification channel (thread mode), and transcript channel, using channel-level and guild-level checks as appropriate.
  • Update reply formatting to render missing permissions grouped by location with a title and footer linking docs.

These changes reduce false positives, centralize thread-mode permissions, and provide clearer error messages to users about where permissions are missing.

Needs: TicketsBot-cloud/common#5 ✓

image

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Improvement

Testing

  • Remove all the permissions from the bot and channels / categories that it uses (it should still have manage roles globally)
  • Then try to open a ticket with each mode
  • Play around with the permissions and see how they react

Checklist

  • My code follows the style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Make permission checking mode-aware and group missing perms by location.

- Adjust server-wide permission list to depend on settings.UseThreads to avoid reporting irrelevant missing permissions. Append standard permissions after mode-specific ones.
- In panel permission checks, treat a panel as using threads if either global settings or the panel enable threads. Use logic.ThreadPermissions for thread-mode channel checks and simplify assembled permission slices.
- Add ThreadPermissions constant in bot/logic/discordpermissions.go for reuse.
- Rewrite findMissingPermissions to return labeled missing-permission groups (panel channel, notification channel, transcript channel) instead of a flat list; check primary channel, optional notification channel (thread mode), and transcript channel, using channel-level and guild-level checks as appropriate.
- Update reply formatting to render missing permissions grouped by location with a title and footer linking docs.

These changes reduce false positives, centralize thread-mode permissions, and provide clearer error messages to users about where permissions are missing.
biast12 added 4 commits April 12, 2026 12:48
Replace local permission constants/usages with the centralized github.com/TicketsBot-cloud/common/botpermissions package across the codebase. Updated imports and calls to BuildPermissions to use botpermissions.StandardPermissions, MinimalPermissions, ThreadModeRequired, NotifChannelRequired, TranscriptChannelRequired, and ChannelModeRequired where appropriate. Removed duplicate permission arrays from bot/logic/discordpermissions.go and adjusted code to copy/append permission slices safely. Also enabled a local replace for the common module in go.mod. This centralizes permission definitions and reduces duplication.
Replace manual permission aggregation with botpermissions.EffectivePermissions and consolidate data fetching into fetchGuildData/fetchChannelData/buildRoleMap helpers. Simplifies HasPermissions/HasPermissionsChannel and GetMissingPermissions* by delegating to centralized logic, removes many in-file permission helpers, and updates imports accordingly. Keeps existing error handling (sentry) and preserves administrator short-circuit behavior.
@github-actions github-actions Bot added the needs:bump_common PR references common repo changes label Apr 25, 2026
Uncomment the replace directive for github.com/TicketsBot-cloud/common in go.mod to point to the local ../common module. This allows building and testing against the local copy of the common package during development; other replace directives remain unchanged.
@github-actions github-actions Bot added the needs:gomod_comment go.mod has uncommented local replace directives label Apr 25, 2026
BenHall-1
BenHall-1 previously approved these changes Apr 26, 2026
@BenHall-1

Copy link
Copy Markdown
Member

@biast12 good to bump when you are

@github-actions github-actions Bot removed the needs:gomod_comment go.mod has uncommented local replace directives label Apr 26, 2026
@biast12 biast12 removed the needs:bump_common PR references common repo changes label Apr 26, 2026
@biast12

biast12 commented Apr 26, 2026

Copy link
Copy Markdown
Contributor Author

bumped!

@github-actions github-actions Bot added the needs:bump_common PR references common repo changes label Jun 21, 2026
BenHall-1
BenHall-1 previously approved these changes Jun 21, 2026
Update ticket claim and unclaim permission overwrites to use the shared botpermissions.StandardPermissions definition.
Capture fetchChannelData failures in Sentry before returning false from HasPermissionsChannel, improving visibility into permission-check failures.
Add channel permission validation for configured overflow categories, require EmbedLinks for transcript channels, and ensure channel-mode permissions are checked for panel-less opens.
Apply channel, thread, notification, pending-category, and transcript permissions consistently across admin diagnostics and command replies. Resolve panels from buttons, select menus, and modals, and replace the obsolete permission wrapper with shared bot permission requirements.
Adds admin-specific container builders without premium branding and updates admin commands and debug handlers to use them. Splits permission checks into separate containers and batches responses to stay within Discord component limits.
@github-actions github-actions Bot added the needs:gomod_comment go.mod has uncommented local replace directives label Sep 21, 2026
@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

This PR is blocked

  • needs:bump_common - PR references a common PR but go.mod is not yet bumped

Remove the label(s) above once the underlying dependency bump or comment has landed, and this check will re-run on the next push.

@biast12

biast12 commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

I made a mistake is the old common PR, so here is a fix for that: TicketsBot-cloud/common#12

Ensure permission diagnostics acknowledge interactions before sending follow-ups, split responses by component and text limits, and apply thread and pending-category permissions correctly. Also fix pin permission checks to use the ticket category.
@BenHall-1

Copy link
Copy Markdown
Member

Good to bump @biast12

Use the latest published common module version and disable the local replacement so builds resolve the remote dependency.
@github-actions github-actions Bot removed needs:bump_common PR references common repo changes needs:gomod_comment go.mod has uncommented local replace directives labels Sep 27, 2026
@biast12

biast12 commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

@BenHall-1 bumped!!

Wrap missing permission names in backticks in server-wide and channel permission diagnostics for clearer Markdown rendering.
@github-actions github-actions Bot added the needs:bump_common PR references common repo changes label Oct 14, 2026
Update missing-permission location detection to rely on the returned channel ID instead of the success flag, while ignoring the unused boolean result.
@biast12 biast12 removed the needs:bump_common PR references common repo changes label Oct 14, 2026
Use the channel type when displaying missing View Channel permissions in admin diagnostics and ticket opening errors. Also normalize botpermissions import ordering in related handlers.
@github-actions github-actions Bot added the needs:bump_common PR references common repo changes label Oct 14, 2026
@biast12

biast12 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

fyi it doesn't need a common bump, it's on the latest one right now. Ben, you might have to bypass the required check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:bump_common PR references common repo changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants