RocketChat / Rocket.Chat.ReactNative

Rocket.Chat mobile clients
https://rocket.chat
MIT License
1.91k stars 1.14k forks source link

List of pinned messages includes message editing history #5751

Open paulchen opened 1 week ago

paulchen commented 1 week ago

Description:

In the list of pinned messages for a certain channel, messages that have been edited are shown multiple times.

Environment Information:

Steps to reproduce:

  1. Login as an admin and make sure "Keep Per Message Editing History" is enabled as described in https://docs.rocket.chat/use-rocket.chat/user-management/message-auditor/audit-edits-deletions-and-encrypted-communications.
  2. Login with a user that has the "Pin Message" privilege for a certain channel.
  3. Navigate to that channel.
  4. Write a message and submit it.
  5. Pin that message.
  6. By clicking on the channel name and choosing "Pinned", make sure you see the message there.
  7. Now go back and edit the message.
  8. Click on the channel name again and choose "Pinned".

Expected behavior:

Only the current version of the message is shown.

Actual behavior:

Both the current and the old version of the message are shown.

https://github.com/RocketChat/Rocket.Chat.ReactNative/assets/404840/71f9d80c-1bb0-4a38-9171-8a4ff43de8eb

Additional context:

Apparently, the app (or Rocket.Chat's backend API) lacks a condition to filter out old revisions of messages.

An item of the message editing history contains the keys parent and hidden which may be used for such a condition:

{
  "_id": "6671e3bc6457df225bc89d9e",
  "rid": "6671e39a6457df225bc89d9a",
  "msg": "test",
  "ts": "2024-06-18T19:44:38.745Z",
  "u": {
    "_id": "xq7oE4mtb2nEcfe2m",
    "username": "paulchen",
    "name": "xx"
  },
  "_updatedAt": "2024-06-18T19:45:00.678Z",
  "urls": [],
  "mentions": [],
  "channels": [],
  "md": [
    {
      "type": "PARAGRAPH",
      "value": [
        {
          "type": "PLAIN_TEXT",
          "value": "test"
        }
      ]
    }
  ],
  "pinned": true,
  "pinnedAt": "2024-06-18T19:44:47.656Z",
  "pinnedBy": {
    "_id": "xq7oE4mtb2nEcfe2m",
    "username": "paulchen"
  },
  "_hidden": true,
  "parent": "EfxP8yY3hZe4Isgge",
  "editedAt": "2024-06-18T19:45:00.678Z",
  "editedBy": {
    "_id": "xq7oE4mtb2nEcfe2m",
    "username": "paulchen"
  }
}

The current revision of the message does not include these keys:

{
  "_id": "EfxP8yY3hZe4Isgge",
  "rid": "6671e39a6457df225bc89d9a",
  "msg": "test test",
  "ts": "2024-06-18T19:44:38.745Z",
  "u": {
    "_id": "xq7oE4mtb2nEcfe2m",
    "username": "paulchen",
    "name": "xx"
  },
  "_updatedAt": "2024-06-18T19:45:00.735Z",
  "urls": [],
  "mentions": [],
  "channels": [],
  "md": [
    {
      "type": "PARAGRAPH",
      "value": [
        {
          "type": "PLAIN_TEXT",
          "value": "test test"
        }
      ]
    }
  ],
  "pinned": true,
  "pinnedAt": "2024-06-18T19:44:47.656Z",
  "pinnedBy": {
    "_id": "xq7oE4mtb2nEcfe2m",
    "username": "paulchen"
  },
  "editedAt": "2024-06-18T19:45:00.731Z",
  "editedBy": {
    "_id": "xq7oE4mtb2nEcfe2m",
    "username": "paulchen"
  }
}
diegolmello commented 1 week ago

Looks like an issue on backend, right? @paulchen

paulchen commented 1 week ago

Looks like an issue on backend, right? @paulchen

Maybe.

However, I don't know the design of the app.

Therefore, I reported the problem for the app where I observed it.

As an additional information, the web version works correctly:

image

gursewaktut commented 3 days ago

Hi @diegolmello, I believe I have fixed this issue.

https://github.com/RocketChat/Rocket.Chat.ReactNative/assets/122689397/075e390c-83c5-428d-8f9e-feef3eae04b6

Can you assign this issue to me? and I will link the pull request to this issue.