RocketChat / RocketChat/Rocket.Chat
Inconsistent implementation of user `type` field
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
There is a type field on the user schema that isn't returning the correct assignment for bots created by an admin. The only time it seems to assign the type as bot is for the internal Rocket.Cat user.
It would be good for the type to be set as bot whenever the bot role is given, because by default, bots don't have permission query the role field through the API, their only way to determine bots from other users in a request would be the type field.
Here's an example API result from my local instance where I have the default admin and bot, plus another "Mock" user and "Bot" - showing the bot gets the "user" type.
[
{
"name": "Administrator",
"username": "admin",
"status": "away",
"type": "user",
"_id": "Ymuzcj8dhFZ2i7k89"
},
{
"name": "Bot",
"username": "bot",
"status": "online",
"type": "user",
"_id": "TFGnsAWgwEMrhEYBq"
},
{
"name": "Mock User",
"username": "mock",
"status": "online",
"type": "user",
"_id": "4Q76Aj9Tdbm4mM2WR"
},
{
"name": "Rocket.Cat",
"username": "rocket.cat",
"status": "online",
"type": "bot",
"_id": "rocket.cat"
}
]
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 by tracing the user schema's type assignment and the handling of the bot role, then reproduce the API response shown in the issue with an admin-created bot. Done means users granted the bot role return type "bot" through the API, while ordinary users continue to return type "user".
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100