Skip to content

fix: Encrypted toggle ignored when creating a discussion - #41030

Open
codewithfourtix wants to merge 2 commits into
RocketChat:developfrom
codewithfourtix:fix/create-discussion-encrypted-flag
Open

codewithfourtix wants to merge 2 commits into
RocketChat:developfrom
codewithfourtix:fix/create-discussion-encrypted-flag

Conversation

@codewithfourtix

@codewithfourtix codewithfourtix commented Jun 21, 2026 •

Copy link
Copy Markdown

Proposed changes (including videos or screenshots)

The Encrypted toggle in the Create Discussion dialog was destructured in handleCreate but never included in the
rooms.createDiscussion payload. As a result, discussions created from an unencrypted parent room were always created
unencrypted, regardless of the toggle state.

This passes the selected encrypted value to the endpoint, which — along with the REST schema
(RoomsCreateDiscussionProps / RoomsCreateDiscussionSchema) and the server-side createDiscussion handler —
already accepts and honors it. No API or schema changes were required; only the client payload was missing the field.

A regression test was added to CreateDiscussion.spec.tsx that enables the encrypted toggle on an unencrypted parent
room and asserts the rooms.createDiscussion endpoint is called with encrypted: true.

Issue(s)

Closes #39443

Steps to test or reproduce

  1. Have (or create) an unencrypted channel.
  2. Create a discussion inside it and enable the Encrypted toggle.
  3. Create the discussion and open it.
  • Before: the discussion is created unencrypted despite the toggle being on.
  • After: the discussion is created encrypted, matching the toggle.

Further comments

This is a one-line client fix — the only missing piece was forwarding the already-supported encrypted flag from the
form to the endpoint. The accompanying test guards against the field being dropped from the payload again.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Fixed the Encrypted toggle in the Create Discussion flow to properly include the user’s encryption selection when creating from an unencrypted parent room, ensuring the discussion is created with the intended encrypted state.

The "Encrypted" toggle in the Create Discussion dialog was destructured
in handleCreate but never included in the rooms.createDiscussion payload.
As a result, discussions created from an unencrypted parent room were
always created unencrypted, regardless of the toggle state.

Pass the selected `encrypted` value to the endpoint (which, along with
the REST schema, already supports it) and add a regression test.

Closes RocketChat#39443
@codewithfourtix
codewithfourtix requested a review from a team as a code owner June 21, 2026 08:49
@changeset-bot

changeset-bot Bot commented Jun 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cbf8c79

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dionisio-bot

dionisio-bot Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@coderabbitai

coderabbitai Bot commented Jun 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bd560027-789f-49cc-ad21-dacef16e1574

📥 Commits

Reviewing files that changed from the base of the PR and between d065200 and cbf8c79.

📒 Files selected for processing (1)
  • apps/meteor/client/components/CreateDiscussion/CreateDiscussion.spec.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/meteor/client/components/CreateDiscussion/CreateDiscussion.spec.tsx
📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: cubic · AI code reviewer

Walkthrough

A one-line fix adds the encrypted boolean field to the POST /v1/rooms.createDiscussion request payload in CreateDiscussion.tsx. A new test suite with two cases verifies the field is correctly submitted for both enabled and disabled toggle states. A patch changeset is added for @rocket.chat/meteor.

Changes

Encrypted flag fix in Create Discussion

Layer / File(s) Summary
Payload fix, submission tests, and changeset
apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx, apps/meteor/client/components/CreateDiscussion/CreateDiscussion.spec.tsx, .changeset/fix-create-discussion-encrypted-flag.md
CreateDiscussion.tsx now passes encrypted in the API call payload. A new Encrypted flag submission test suite adds two cases: one enables the encrypted toggle after selecting an unencrypted parent room and asserts the API payload includes encrypted: true; the second leaves the toggle off and asserts encrypted: false. A patch changeset documents the fix.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Suggested reviewers

  • aleksandernsilva
  • juliajforesti
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main bug fix: the Encrypted toggle was being ignored when creating discussions.
Linked Issues check ✅ Passed The pull request fully addresses issue #39443 by including the encrypted flag in the rooms.createDiscussion payload and adding regression tests.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the encrypted flag omission and adding test coverage, with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 3 files

Re-trigger cubic

@Shevilll Shevilll 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.

Clean fix. I traced the form state to be sure this doesn't regress the encrypted-parent case: encrypted defaults to encryptedParentRoom and setValue('encrypted', room.encrypted === true) runs on parent selection, so when the parent is encrypted the payload now correctly carries encrypted: true rather than dropping it. The existing reply: encrypted ? undefined : firstMessage line already lines up with this. Good to have the regression test alongside the fix.

One small suggestion to harden the test: add the inverse assertion — toggle left off on an unencrypted parent → endpoint called with encrypted: false (or the field absent). Right now the test only proves true is forwarded; covering the off case guards against the field accidentally being hardcoded truthy in a future change.

Adds the inverse assertion suggested in review: with the encrypted toggle
left off on an unencrypted parent room, the rooms.createDiscussion
endpoint is called with encrypted: false. Guards against the field being
accidentally hardcoded truthy in a future change.
@codewithfourtix

Copy link
Copy Markdown
Author

@Shevilll Thanks for the careful trace i agreed on the encrypted-parent case. Added the inverse assertion as suggested: unencrypted parent + toggle left off now asserts the endpoint receives encrypted: false, so we cover both the true and false paths and guard against the field being hardcoded truthy later -Pushed in cbf8c79

@CLAassistant

CLAassistant commented Nov 5, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: 'encrypted' flag not included in rooms.createDiscussion request when creating encrypted discussions

3 participants