Skip to content

feat(bot-discord): sala empresarial private rooms#450

Open
gvieira18 wants to merge 6 commits into
4.xfrom
story/448-sala-empresarial
Open

feat(bot-discord): sala empresarial private rooms#450
gvieira18 wants to merge 6 commits into
4.xfrom
story/448-sala-empresarial

Conversation

@gvieira18

@gvieira18 gvieira18 commented Jul 24, 2026

Copy link
Copy Markdown
Member

Summary

  • Add /sala-empresarial empresa:<slug>, converting a /sala-tracked voice room into a private company room by stamping Discord permission overwrites — deny @everyone and allow the selected Empresa Parceira's Partner Role for connect, speak, use_vad, send_messages and read_message_history (voice + the room's built-in text chat). VIEW_CHANNEL stays untouched (visible-but-locked) and MENTION_EVERYONE keeps category inheritance.
  • Put the decision (guards + role resolution + overwrite plan) in a pure, unit-tested ConfigureEmpresarialRoomAction; the command edge only performs the setPermissions I/O.
  • Gate by Partner Role membership, not room ownership — any member of the selected company can privatize the room (rejects not-in-tracked-room / unknown-company / missing-partner-role, all ephemeral).
  • Add a flat bot-discord.roles.partners registry (slug => role id), seeded with brd and 3p; onboarding a new partner is one env + one config line.
  • Ship the module glossary (CONTEXT) entries and ADR-0001 documenting the design.

Notes

  • Deviates slightly from the original feat(bot-discord): sala empresarial — role-gated private voice rooms #448 permission list: send_messages was added after a live server test showed outsiders could still post in the room's text chat.
  • Stateless by design — only /sala-tracked rooms are eligible and DynamicVoiceTask auto-deletes them when empty, so overwrites die with the channel. No revert command.

Test plan

  • Member holding the partner role, inside their /sala room → /sala-empresarial empresa:brd privatizes it; outsiders can't connect, speak, or post in chat, but the room stays visible.
  • Same room, run by a teammate who didn't create it → still succeeds (role-gated, not owner-gated).
  • Pick a company whose role you don't hold → ephemeral rejection, no overwrites stamped.
  • Run outside any /sala room (permanent channel or no voice) → ephemeral rejection.
  • Re-run on an already-configured room → harmless re-stamp, no error.

Closes #448

Screenshots

Ephemeral replies, captured on a test guild (/sala-empresarial).

Company picker — choices built from the partners registry (BRD, 3P):
Screenshot from 2026-07-24 09-30-16

Success — room privatized for BRD:
Screenshot from 2026-07-24 09-42-33

Rejected — caller doesn't hold the selected company's Partner Role (missing-partner-role):
Screenshot from 2026-07-24 09-30-39

Rejected — caller isn't inside a /sala-tracked room (not-in-tracked-room):
Screenshot from 2026-07-24 09-29-14

Add /sala-empresarial, converting a /sala-tracked voice room into a
private company room by stamping Discord permission overwrites: deny
@everyone and allow the selected Empresa Parceira's Partner Role for
connect, speak, use_vad, send_messages and read_message_history. The
last two lock the room's built-in text chat; VIEW_CHANNEL is left
untouched (visible-but-locked) and MENTION_EVERYONE keeps its category
inheritance.

The decision (guards + role resolution + overwrite plan) lives in a
pure, unit-tested ConfigureEmpresarialRoomAction; the command edge only
performs the setPermissions I/O. Gating is by Partner Role membership,
not room ownership, so any company member can privatize the room.

Partners are a flat bot-discord.roles.partners registry (slug => role
id); onboarding a new partner is one env + one line.

Closes #448
@gvieira18
gvieira18 requested a review from a team July 24, 2026 12:42
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds /sala-empresarial, partner-role configuration, immutable decision and overwrite DTOs, rejection reasons, Discord permission updates, an ADR, glossary entries, and unit tests covering validation, role selection, success, rejection, and idempotency.

Suggested labels: bot-discord

Suggested reviewers: clintonrocha98

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The implementation hides rooms by denying VIEW_CHANNEL and adds SEND_MESSAGES, but the issue requires VIEW_CHANNEL unchanged and only the listed permissions. Keep VIEW_CHANNEL and MENTION_EVERYONE unchanged and align the overwrite set with the issue requirements.
Out of Scope Changes check ⚠️ Warning package.json bumps concurrently from 10.0.3 to 10.0.4, which is unrelated to the /sala-empresarial feature. Remove the dependency bump unless it is required by the feature and documented in the issue.
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and matches the main change: adding private empresarial rooms to bot-discord.
Description check ✅ Passed The description matches the room-privacy feature, action split, partner registry, and test coverage.

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

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 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
`@app-modules/bot-discord/docs/adr/0001-sala-empresarial-role-gated-private-rooms.md`:
- Around line 16-17: Update the ADR statement describing MENTION_EVERYONE to say
the permission remains inherited or unchanged, rather than guaranteeing it is
denied. Keep the existing VIEW_CHANNEL and visible-but-locked behavior
description intact.

In `@app-modules/bot-discord/src/SlashCommands/SalaEmpresarialCommand.php`:
- Around line 86-113: Update applyOverwrites to remove existing configured
partner-role permission overwrites before applying the selected
plan->partnerRoleId permissions. Preserve the everyone overwrite and the
selected partner role, and ensure re-stamping a room replaces the previous
partner access rather than accumulating roles.
- Around line 108-113: In the permission-update flow, reorder the operations so
the $partnerRole setPermissions call and its await complete before the
$everyoneRole denial. Keep both existing permission payloads unchanged, ensuring
a failed partner-role write does not leave the channel globally locked.
- Around line 106-117: Defer the interaction ephemerally at the start of the try
block in SalaEmpresarialCommand before either setPermissions call. Keep both
permission updates and await operations afterward, then complete the deferred
interaction with the existing success response rather than attempting a new
initial reply.
🪄 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: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: fb8cda84-cb5e-4fe1-a588-55e94ad60573

📥 Commits

Reviewing files that changed from the base of the PR and between 49dcddb and f60a26e.

📒 Files selected for processing (10)
  • app-modules/bot-discord/CONTEXT.md
  • app-modules/bot-discord/config/bot-discord.php
  • app-modules/bot-discord/docs/adr/0001-sala-empresarial-role-gated-private-rooms.md
  • app-modules/bot-discord/src/Actions/VoiceChannel/ConfigureEmpresarialRoomAction.php
  • app-modules/bot-discord/src/DTO/EmpresarialOverwritePlan.php
  • app-modules/bot-discord/src/DTO/EmpresarialRoomDecision.php
  • app-modules/bot-discord/src/Enums/EmpresarialRejectionReason.php
  • app-modules/bot-discord/src/SlashCommands/SalaEmpresarialCommand.php
  • app-modules/bot-discord/tests/Unit/Actions/VoiceChannel/ConfigureEmpresarialRoomActionTest.php
  • app-modules/bot-discord/tests/Unit/Enums/EmpresarialRejectionReasonTest.php

Comment thread app-modules/bot-discord/src/SlashCommands/SalaEmpresarialCommand.php Outdated
Apply the partner-role allow overwrite before the @everyone deny so a
failed partner write leaves the room public instead of fully locked
(deny-first could strand everyone out of the room).

Also reword ADR-0001: the command leaves MENTION_EVERYONE and
VIEW_CHANNEL unchanged rather than guaranteeing MENTION_EVERYONE is
denied — it keeps whatever the category inherits.
Deny VIEW_CHANNEL to @everyone (and allow it for the Partner Role) so a
Sala Empresarial is fully private: non-members no longer see the room or
its occupant list, and any non-partner connected at conversion time is
force-disconnected by Discord.
@YuriSouzaDev

Copy link
Copy Markdown
Contributor

Dúvida legítima:

Visto que uma pessoa sem a tag não pode entrar na sala, mas um admin ou alguma outra tag que permita movimentar membros entre as salas consegue colocar alguem sem a tag da partner dentro da sala? Pois sem que comandos admin sobrepoem qualquer checgame.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app-modules/bot-discord/docs/adr/0001-sala-empresarial-role-gated-private-rooms.md (1)

36-40: 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

Revoke stale partner-role access when changing companies.

The command adds the newly selected role’s allow overwrite but does not remove a previous partner-role overwrite. Reconfiguring brd to 3p can therefore leave both companies with access, contradicting “private for the selected company.” Remove stale configured partner-role overwrites or reject reconfiguration.

🤖 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
`@app-modules/bot-discord/docs/adr/0001-sala-empresarial-role-gated-private-rooms.md`
around lines 36 - 40, Update the empresarial room reconfiguration behavior
described in the ADR so selecting a new company removes any previously
configured partner-role overwrites before applying the selected role’s allow
overwrite, preserving access for only the current company; alternatively,
explicitly reject reconfiguration. Align the stateless/private-room description
with the chosen behavior.
🤖 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
`@app-modules/bot-discord/docs/adr/0001-sala-empresarial-role-gated-private-rooms.md`:
- Around line 14-19: Resolve the conflicting VIEW_CHANNEL behavior across the
ADR, overwrite plan, command implementation, tests, and documentation: choose
whether the command denies it for `@everyone` or leaves it inherited/unchanged,
then make every affected artifact consistently implement and assert that choice,
including room discoverability and occupant visibility.
- Around line 48-51: Update the privacy guarantees in this ADR, including the
statements around channel visibility and non-member disconnection, to explicitly
exclude Discord members with the ADMINISTRATOR permission. Clarify that
administrators can bypass the `@everyone` VIEW_CHANNEL deny and may see or access
empresarial rooms, or revise the design to enforce privacy beyond guild
permission checks.

---

Outside diff comments:
In
`@app-modules/bot-discord/docs/adr/0001-sala-empresarial-role-gated-private-rooms.md`:
- Around line 36-40: Update the empresarial room reconfiguration behavior
described in the ADR so selecting a new company removes any previously
configured partner-role overwrites before applying the selected role’s allow
overwrite, preserving access for only the current company; alternatively,
explicitly reject reconfiguration. Align the stateless/private-room description
with the chosen behavior.
🪄 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: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 182c01ab-a371-41ab-8115-9e92ded60ba2

📥 Commits

Reviewing files that changed from the base of the PR and between f337064 and 4132d97.

📒 Files selected for processing (4)
  • app-modules/bot-discord/CONTEXT.md
  • app-modules/bot-discord/docs/adr/0001-sala-empresarial-role-gated-private-rooms.md
  • app-modules/bot-discord/src/DTO/EmpresarialOverwritePlan.php
  • app-modules/bot-discord/tests/Unit/Actions/VoiceChannel/ConfigureEmpresarialRoomActionTest.php
🚧 Files skipped from review as they are similar to previous changes (3)
  • app-modules/bot-discord/CONTEXT.md
  • app-modules/bot-discord/src/DTO/EmpresarialOverwritePlan.php
  • app-modules/bot-discord/tests/Unit/Actions/VoiceChannel/ConfigureEmpresarialRoomActionTest.php

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.

feat(bot-discord): sala empresarial — role-gated private voice rooms

2 participants