RocketChat / RocketChat/Rocket.Chat
`findCustomRoles` in `src/models/Roles.ts` produce "false negative".
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Hi there,
I've found that this specific snippet is producing a false negative on older rocket.chat instances.
https://github.com/RocketChat/Rocket.Chat/blob/85fc0ddca134a875b10133751182eb9c65fd4724/packages/models/src/models/Roles.ts#L139-L145
In my Rocket.Chat instance, I have custom roles set up which are already a few years old.
When looking in the db, they're all missing the protected tag within the db.
I stumbled over this issue, when I wanted to get a specific custom role, but my code failed, saying that it couldn't find the role in question.
Could this code be changed, so that it negates everything? e.g. instead of hard-match protected: false, match for the opposite with the protected: { $ne: true }, I think this should also cover non-existend protected tags like in my case.
Thanks.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/models/src/models/Roles.ts at the findCustomRoles query around lines 139-145 and inspect how the protected field is matched. Reproduce the lookup with an older custom role that lacks protected, then verify that such roles are returned while roles marked protected still are not.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, typescript
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100