From d1f0ae386540126412fa75148e9a644e3638bb3f Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 21 Mar 2023 11:26:25 +0100 Subject: [PATCH] refs #4858 fix: filtro corregido --- back/methods/chat/sendCheckingPresence.js | 3 +++ back/methods/chat/sendQueued.js | 19 +++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 3eaf6b86b..29232490a 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -38,6 +38,9 @@ module.exports = Self => { if (!recipient) throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`); + if (process.env.NODE_ENV == 'test') + message = `[Test:Environment to user ${userId}] ` + message; + const chat = await models.Chat.create({ senderFk: sender.id, recipient: `@${recipient.name}`, diff --git a/back/methods/chat/sendQueued.js b/back/methods/chat/sendQueued.js index 8a0bdee34..ef1a417ab 100644 --- a/back/methods/chat/sendQueued.js +++ b/back/methods/chat/sendQueued.js @@ -19,12 +19,11 @@ module.exports = Self => { const chats = await models.Chat.find({ where: { status: { - neq: { - and: [ - 'sent', - 'sending' - ] - } + nin: [ + 'sent', + 'sending' + ] + }, attempts: {lt: 3} } @@ -34,16 +33,16 @@ module.exports = Self => { if (chat.checkUserStatus) { try { await Self.sendCheckingUserStatus(chat); - await updateChat(chat, 'sent'); + await Self.updateChat(chat, 'sent'); } catch (error) { - await updateChat(chat, 'error', error); + await Self.updateChat(chat, 'error', error); } } else { try { await Self.sendMessage(chat.senderFk, chat.recipient, chat.message); - await updateChat(chat, 'sent'); + await Self.updateChat(chat, 'sent'); } catch (error) { - await updateChat(chat, 'error', error); + await Self.updateChat(chat, 'error', error); } } }