Skip to content

findCustomRoles in src/models/Roles.ts produce "false negative". #40798

Description

@VeldoraTheDragon

Hi there,
I've found that this specific snippet is producing a false negative on older rocket.chat instances.

findCustomRoles(options?: FindOptions<IRole>): FindCursor<IRole> {
const query: Filter<IRole> = {
protected: false,
};
return this.find(query, options || {});
}

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions