fix: send messages to channels
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
882c4cc3d7
commit
e5349ec7ed
|
@ -33,14 +33,14 @@ module.exports = Self => {
|
||||||
await Self.sendCheckingUserStatus(chat);
|
await Self.sendCheckingUserStatus(chat);
|
||||||
await updateChat(chat, sentStatus);
|
await updateChat(chat, sentStatus);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await updateChat(chat, errorStatus);
|
await updateChat(chat, errorStatus, 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, sentStatus);
|
await updateChat(chat, sentStatus);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await updateChat(chat, errorStatus);
|
await updateChat(chat, errorStatus, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ module.exports = Self => {
|
||||||
const channelName = department && department.chatName;
|
const channelName = department && department.chatName;
|
||||||
|
|
||||||
if (channelName)
|
if (channelName)
|
||||||
return Self.sendMessage(chat.senderFk, `#${channelName}`, `@${recipient.name} ➔ ${message}`);
|
return Self.sendMessage(chat.senderFk, `#${channelName}`, `@${recipient.name} ➔ ${chat.message}`);
|
||||||
else
|
else
|
||||||
return Self.sendMessage(chat.senderFk, `@${recipient.name}`, chat.message);
|
return Self.sendMessage(chat.senderFk, `@${recipient.name}`, chat.message);
|
||||||
} else
|
} else
|
||||||
|
@ -127,12 +127,14 @@ module.exports = Self => {
|
||||||
*
|
*
|
||||||
* @param {object} chat - The chat
|
* @param {object} chat - The chat
|
||||||
* @param {string} status - The new status
|
* @param {string} status - The new status
|
||||||
|
* @param {string} error - The error
|
||||||
* @return {Promise} - The request promise
|
* @return {Promise} - The request promise
|
||||||
*/
|
*/
|
||||||
async function updateChat(chat, status) {
|
async function updateChat(chat, status, error) {
|
||||||
return chat.updateAttributes({
|
return chat.updateAttributes({
|
||||||
status: status,
|
status: status,
|
||||||
attempts: ++chat.attempts
|
attempts: ++chat.attempts,
|
||||||
|
error: error
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,9 @@
|
||||||
},
|
},
|
||||||
"attempts": {
|
"attempts": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
},
|
||||||
|
"error": {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"acls": [{
|
"acls": [{
|
||||||
|
|
Loading…
Reference in New Issue