Skip to content

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

Open
biast12 wants to merge 4 commits intomasterfrom
RM-254
Open

RM-254: Refactor permission checks for thread/channel modes#134
biast12 wants to merge 4 commits intomasterfrom
RM-254

Conversation

@biast12
Copy link
Copy Markdown
Contributor

@biast12 biast12 commented Apr 11, 2026

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 3 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.
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