4858-chat_realTime #1313

Merged
vicent merged 11 commits from 4858-chat_realTime into dev 2023-03-24 10:12:25 +00:00
2 changed files with 12 additions and 10 deletions
Showing only changes of commit d1f0ae3865 - Show all commits

View File

@ -38,6 +38,9 @@ module.exports = Self => {
if (!recipient) if (!recipient)
throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`); throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`);
vicent marked this conversation as resolved Outdated

aci faltaria un try catch i el rollback

aci faltaria un try catch i el rollback
Outdated
Review

Quitada transaccion

Quitada transaccion
if (process.env.NODE_ENV == 'test')
message = `[Test:Environment to user ${userId}] ` + message;
const chat = await models.Chat.create({ const chat = await models.Chat.create({
senderFk: sender.id, senderFk: sender.id,
recipient: `@${recipient.name}`, recipient: `@${recipient.name}`,

View File

@ -19,12 +19,11 @@ module.exports = Self => {
const chats = await models.Chat.find({ const chats = await models.Chat.find({
where: { where: {
status: { status: {
neq: { nin: [
and: [ 'sent',
'sent', 'sending'
'sending' ]
]
}
}, },
attempts: {lt: 3} attempts: {lt: 3}
} }
@ -34,16 +33,16 @@ module.exports = Self => {
if (chat.checkUserStatus) { if (chat.checkUserStatus) {
try { try {
await Self.sendCheckingUserStatus(chat); await Self.sendCheckingUserStatus(chat);
await updateChat(chat, 'sent'); await Self.updateChat(chat, 'sent');
} catch (error) { } catch (error) {
await updateChat(chat, 'error', error); await Self.updateChat(chat, 'error', error);
} }
} else { } else {
try { try {
await Self.sendMessage(chat.senderFk, chat.recipient, chat.message); await Self.sendMessage(chat.senderFk, chat.recipient, chat.message);
await updateChat(chat, 'sent'); await Self.updateChat(chat, 'sent');
} catch (error) { } catch (error) {
await updateChat(chat, 'error', error); await Self.updateChat(chat, 'error', error);
} }
} }
} }