refs #4858 fix: filtro corregido
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2023-03-21 11:26:25 +01:00
parent f06fc92ae8
commit d1f0ae3865
2 changed files with 12 additions and 10 deletions

View File

@ -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}`,

View File

@ -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);
}
}
}