diff --git a/back/methods/chat/sendQueued.js b/back/methods/chat/sendQueued.js index cf80817e5..ab94a1746 100644 --- a/back/methods/chat/sendQueued.js +++ b/back/methods/chat/sendQueued.js @@ -33,14 +33,14 @@ module.exports = Self => { await Self.sendCheckingUserStatus(chat); await updateChat(chat, sentStatus); } catch (error) { - await updateChat(chat, errorStatus); + await updateChat(chat, errorStatus, error); } } else { try { await Self.sendMessage(chat.senderFk, chat.recipient, chat.message); await updateChat(chat, sentStatus); } catch (error) { - await updateChat(chat, errorStatus); + await updateChat(chat, errorStatus, error); } } } @@ -75,7 +75,7 @@ module.exports = Self => { const channelName = department && department.chatName; if (channelName) - return Self.sendMessage(chat.senderFk, `#${channelName}`, `@${recipient.name} ➔ ${message}`); + return Self.sendMessage(chat.senderFk, `#${channelName}`, `@${recipient.name} ➔ ${chat.message}`); else return Self.sendMessage(chat.senderFk, `@${recipient.name}`, chat.message); } else @@ -127,12 +127,14 @@ module.exports = Self => { * * @param {object} chat - The chat * @param {string} status - The new status + * @param {string} error - The error * @return {Promise} - The request promise */ - async function updateChat(chat, status) { + async function updateChat(chat, status, error) { return chat.updateAttributes({ status: status, - attempts: ++chat.attempts + attempts: ++chat.attempts, + error: error }); } diff --git a/back/models/chat.json b/back/models/chat.json index 8fc3a6304..0d6328544 100644 --- a/back/models/chat.json +++ b/back/models/chat.json @@ -32,6 +32,9 @@ }, "attempts": { "type": "number" + }, + "error": { + "type": "string" } }, "acls": [{