verdigado / rocketchat2matrix

Script to migrate Rocket.Chat databases to Matrix Synapse. Mirror of https://git.verdigado.com/NB-Public/rocketchat2matrix
GNU Affero General Public License v3.0
14 stars 6 forks source link

Messages deleted using `"_hidden":true` are not marked as deleted/are not ignored during migration #34

Open drygdryg opened 1 month ago

drygdryg commented 1 month ago

Rocket.Chat in some cases sets the "_hidden":true" property instead of deleting a message from MongoDB, which leads to inclusion of such messages in the mongoexport. The proof of this behavior in the Rocket.Chat server side source code: https://github.com/RocketChat/Rocket.Chat/blob/41b1407804ce17bb54b79cda607554c474246f29/apps/meteor/app/lib/server/functions/deleteMessage.ts#L56

The main point is that we cannot just ignore such messages when migrating, in case the message is the beginning of the thread.
A possible solution is to migrate the message and then delete it, if the _hidden flag is set. This will allow us to save threads that started with a deleted message.

drygdryg commented 1 month ago

A possible solution is to migrate the message and then delete it, if the _hidden flag is set. This will allow us to save threads that started with a deleted message.

This will not work as required because Rocket.Chat, when deleting a message, adds t: 'rm' to the original MongoDB document and then creates a copy of it setting _hidden: true. We probably need to process messages with type "rm" and ignore messages with _hidden. And after all the messages have been migrated, we need to run an iteration and delete all messages with the "rm" type using the Matrix redact event.