RocketChat / RocketChat/Rocket.Chat

[BUG] `createDirectRoom` server function ignores `subscriptionExtra.open` option

Open
#30,825 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

Description:

The subscriptionExtra options are splatted before the { open } option and thus will always defer to the member count check if the member is not the creator:

https://github.com/RocketChat/Rocket.Chat/blob/develop/apps/meteor/app/lib/server/functions/createDirectRoom.ts#L149-L150

I believe these two lines should be reversed as such:

...(options?.creator !== member._id && { open: members.length > 2 }),
...options?.subscriptionExtra,

thus allowing calls to createDirectRoom with options: options.subscriptionExtra = { open: true } to be honoured.

Steps to reproduce:

Call createDirectRoom(['user1', 'user2'], {}, { subscriptionExtra: { open: true } })

OR

Post to the /api/v1/im.create endpoint with:

{
  "usernames": "user1,user2",
  "excludeSelf": true
}

(as a user with the view-room-administration permission)

Expected behavior:

For the direct room to be created, and the room "opened" for both users

Actual behavior:

The direct room is created, but is not opened for either user.

Server Setup Information:
  • Version of Rocket.Chat Server: develop branch

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in apps/meteor/app/lib/server/functions/createDirectRoom.ts around lines 149-150 and inspect how subscriptionExtra and the open option are combined. Reproduce with createDirectRoom or the im.create API using the stated options; done when a direct room created with open: true is opened for both users.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.