Skip to content

feat: honor "*" allow-all wildcard in Slack/Mattermost/Twitch user allowlists#605

Open
slvnlrt wants to merge 1 commit into
spacedriveapp:mainfrom
slvnlrt:pr/dm-allow-all-wildcard
Open

feat: honor "*" allow-all wildcard in Slack/Mattermost/Twitch user allowlists#605
slvnlrt wants to merge 1 commit into
spacedriveapp:mainfrom
slvnlrt:pr/dm-allow-all-wildcard

Conversation

@slvnlrt

@slvnlrt slvnlrt commented Jun 26, 2026

Copy link
Copy Markdown

What

Aligns the string-keyed messaging adapters — Slack, Mattermost, and Twitch — to honor a "*" allow-all wildcard in their DM / user allowlists, matching the convention the Signal adapter already uses.

Why

Today only Signal treats "*" as allow-all. The other adapters match user IDs by exact value, so:

  • there is no way to allow every DM/user without enumerating each ID (impractical at organization or community scale), and
  • a list of ["*"] silently matches nobody — a footgun, since it reads like "allow all" but matches only a literal "*" id.

How

A small helper per permission struct, with each adapter's existing inline check routed through it. Behavior is unchanged except that "*" now means allow-all:

  • SlackPermissions::dm_user_allowed / MattermostPermissions::dm_user_allowedfail-closed: an empty list still blocks all DMs; "*" allows all.
  • TwitchPermissions::user_allowedfail-open: an empty list still allows all users (preserving existing behavior); "*" allows all; matching stays case-insensitive.

Each adapter's empty-list semantics are preserved exactly.

Scope

Discord and Telegram parse their allowlists into integer id vectors (Vec<u64> / Vec<i64>), so "*" is not representable there; an allow-all for those would need a separate flag and is left out of scope.

Tests

Adds unit tests for each adapter covering empty / wildcard / exact (and case-insensitive, for Twitch) matching. cargo test --lib is green; cargo fmt --check and cargo clippy are clean.

Note

Adds three new helper methods (SlackPermissions::dm_user_allowed, MattermostPermissions::dm_user_allowed, TwitchPermissions::user_allowed) that encapsulate the permission check logic and support wildcard matching. The implementation updates call sites in slack.rs, mattermost.rs, and twitch.rs to use these helpers, consolidating the duplication and fixing the footgun where ["*"] previously matched nobody. Unit tests cover empty, wildcard, and exact matching scenarios for each adapter, with case-insensitive matching for Twitch.

Written by Tembo for commit d0ee4de. This will update automatically on new commits.

Slack, Mattermost, and Twitch allowlists matched user IDs by exact value
only, so there was no way to allow every DM/user without enumerating each
one — and a list of ["*"] silently matched nobody. The Signal adapter
already treats "*" as an explicit allow-all wildcard; this aligns the other
string-keyed adapters with that convention.

- SlackPermissions::dm_user_allowed / MattermostPermissions::dm_user_allowed
  (fail-closed: an empty list still blocks all DMs; "*" allows all)
- TwitchPermissions::user_allowed (fail-open: an empty list still allows all,
  preserving existing behavior; "*" allows all; matching is case-insensitive)
- the adapters call the new helpers; behavior is unchanged except that "*"
  now means allow-all instead of matching a literal "*" id

Discord and Telegram parse their allowlists into integer id vectors
(Vec<u64> / Vec<i64>), so "*" is not representable there; an allow-all for
those would need a separate flag and is out of scope here.

Adds unit tests covering each adapter's empty / wildcard / exact-match cases.
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds allowlist helper methods for Slack, Twitch, and Mattermost permissions, updates messaging adapters to use those helpers for DM/user filtering, and adds unit tests for wildcard and empty-allowlist behavior.

Changes

Permission allowlist changes

Layer / File(s) Summary
Permission helper methods
src/config/permissions.rs
SlackPermissions, TwitchPermissions, and MattermostPermissions add allowlist helpers for DM or user matching.
Adapter filtering delegation
src/messaging/slack.rs, src/messaging/mattermost.rs, src/messaging/twitch.rs
Slack, Mattermost, and Twitch message filtering now call the new permission helpers instead of inline allowlist checks.
Wildcard tests
src/config/permissions.rs
dm_wildcard_tests adds wildcard, empty-allowlist, exact-match, and Twitch case-insensitive coverage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding wildcard allow-all handling for Slack, Mattermost, and Twitch allowlists.
Description check ✅ Passed The description directly matches the changeset and explains the wildcard behavior, scope, and tests.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/config/permissions.rs (1)

654-654: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use a descriptive variable name instead of p.

These changed tests abbreviate permissions as p; renaming it keeps the test code aligned with the repository naming rule.

As per coding guidelines, src/**/*.rs: “Don't abbreviate variable names. Use queue not q, message not msg, channel not ch.”

Also applies to: 666-666, 685-685, 701-701, 708-708

🤖 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 `@src/config/permissions.rs` at line 654, The test variables are abbreviated as
p, which violates the repository naming rule against short variable names.
Rename the permission variable in the affected test cases to a descriptive name
such as permissions, and update the related usages in the same test block so the
names are consistent with the surrounding Rust code and the existing naming
convention.

Source: Coding guidelines

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

Nitpick comments:
In `@src/config/permissions.rs`:
- Line 654: The test variables are abbreviated as p, which violates the
repository naming rule against short variable names. Rename the permission
variable in the affected test cases to a descriptive name such as permissions,
and update the related usages in the same test block so the names are consistent
with the surrounding Rust code and the existing naming convention.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 698a34f6-c5d0-49bf-ab1e-ac09873577eb

📥 Commits

Reviewing files that changed from the base of the PR and between ac52277 and d0ee4de.

📒 Files selected for processing (4)
  • src/config/permissions.rs
  • src/messaging/mattermost.rs
  • src/messaging/slack.rs
  • src/messaging/twitch.rs

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