Repository navigation
fix: Encrypted toggle ignored when creating a discussion - #41030
codewithfourtix wants to merge 2 commits into
Conversation
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
🦋 Changeset detectedLatest commit: cbf8c79 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (1)
WalkthroughA one-line fix adds the ChangesEncrypted flag fix in Create Discussion
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ 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. Comment |
Shevilll
left a comment
There was a problem hiding this comment.
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.
|
@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 |
Proposed changes (including videos or screenshots)
The Encrypted toggle in the Create Discussion dialog was destructured in
handleCreatebut never included in therooms.createDiscussionpayload. As a result, discussions created from an unencrypted parent room were always createdunencrypted, regardless of the toggle state.
This passes the selected
encryptedvalue to the endpoint, which — along with the REST schema(
RoomsCreateDiscussionProps/RoomsCreateDiscussionSchema) and the server-sidecreateDiscussionhandler —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.tsxthat enables the encrypted toggle on an unencrypted parentroom and asserts the
rooms.createDiscussionendpoint is called withencrypted: true.Issue(s)
Closes #39443
Steps to test or reproduce
Further comments
This is a one-line client fix — the only missing piece was forwarding the already-supported
encryptedflag from theform to the endpoint. The accompanying test guards against the field being dropped from the payload again.
Summary by CodeRabbit