From 8c8a7c437cf274ccf68415438bb34ffb9ac8094e Mon Sep 17 00:00:00 2001 From: Taras Chaika <45912519+TSlashDreamy@users.noreply.github.com> Date: Fri, 17 Nov 2023 14:40:36 +0200 Subject: [PATCH] fixed deleting from the wrong user (#637) --- services/message.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/message.js b/services/message.js index fff8477b..33d09ed8 100644 --- a/services/message.js +++ b/services/message.js @@ -85,7 +85,7 @@ const messageService = { if (!existingChat) throw createForbiddenError() - const deleteResult = await Message.deleteMany({ chat, 'clearedFor.user': { $exists: true } }).exec() + const deleteResult = await Message.deleteMany({ chat, 'clearedFor.user': { $exists: true, $ne: user } }).exec() const updateResult = await Message.updateMany( { chat, 'clearedFor.user': { $exists: false } },