Skip to content

Message reactions persist after the reacting user is deleted #39700

@mossae

Description

@mossae

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: {
":thumbsup:": {
usernames: ["userB"]
}
}

Actual behavior:

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

Example:

reactions: {
":thumbsup:": {
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions