RocketChat / RocketChat/Rocket.Chat

Message reactions persist after the reacting user is deleted

Open
#39,700 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description:

When a user is deleted, their reactions remain attached to messages in the reactions field of the rocketchat_message collection. This creates ghost reactions where a reaction references a username that no longer exists in the users collection.

Rocket.Chat stores reactions using usernames instead of user IDs, and the user deletion process does not currently remove these references.

As a result, message reaction data may contain usernames belonging to users that have already been deleted.

Steps to reproduce:

1. Create two users (User A and User B).

2. Send a message in any channel or room.

3. React to the message using User A.

4. Delete User A from the workspace.

5. Check the message reactions.

Expected behavior:

When a user is deleted, their username should be removed from all message reactions so that no orphan references remain.

Example expected structure:

reactions: {
"👍": {
usernames: ["userB"]
}
}

Actual behavior:

The deleted user's username remains in the message reactions.

Example:

reactions: {
"👍": {
usernames: ["userA", "userB"]
}
}

Even though userA no longer exists in the users collection.

This results in ghost reactions remaining in message data.

Evidence

Reaction before deleting the user

Image

isha.walia reacts to a message and the reaction appears normally.

Reaction after deleting the user

Image

isha.walia has been deleted, but the reaction still appears on the message.

Server Setup Information:

Version of Rocket.Chat Server: 8.3.0

License Type: Community

Number of Users: Not required for reproduction

Operating System: Linux

Deployment Method: Development environment

Number of Running Instances: 1

DB Replicaset Oplog: Enabled

NodeJS Version: 22.16.0

MongoDB Version: 7.2

Client Setup Information

Desktop App or Browser Version: Latest Chrome(145.0.7632.160)

Operating System: Linux

Additional context

Reactions are stored inside the message document using the following structure:

reactions: {
":emoji:": {
usernames: [...]
}
}

Since usernames are stored directly, deleting a user does not automatically remove them from the reaction lists. Cleaning these references during user deletion would prevent orphan reaction entries.

Relevant logs:

The issue results from stale reaction data remaining in the database after user deletion.

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 by tracing the user deletion process and how reactions are stored in the rocketchat_message collection. Reproduce the issue with two users and inspect the reactions field before and after deleting the reacting user. Done means the deleted username is removed from all message reaction lists without affecting remaining users.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, typescript
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.