From a82f7d758451e76f53a2102c08a74773a7f4cba1 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 7 Feb 2020 11:50:09 +0100 Subject: [PATCH 1/4] #2083 Login on auth error --- back/methods/chat/send.js | 1 + 1 file changed, 1 insertion(+) diff --git a/back/methods/chat/send.js b/back/methods/chat/send.js index c36178b0f..2b00df727 100644 --- a/back/methods/chat/send.js +++ b/back/methods/chat/send.js @@ -46,6 +46,7 @@ module.exports = Self => { }).catch(async error => { if (error.statusCode === 401 && !this.resendAttempted) { this.resendAttempted = true; + this.auth = null; return sendMessage(sender, channel, message); } From 375807dec4fdf9fa7def3dc12edd7244dbd0a89b Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 7 Feb 2020 14:04:18 +0100 Subject: [PATCH 2/4] 2089 - Removed mention from message --- back/methods/chat/send.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/back/methods/chat/send.js b/back/methods/chat/send.js index 2b00df727..b0a9431c7 100644 --- a/back/methods/chat/send.js +++ b/back/methods/chat/send.js @@ -31,7 +31,7 @@ module.exports = Self => { const recipient = to.replace('@', ''); if (sender.name != recipient) - return sendMessage(sender, to, `@${sender.name}: ${message} `); + return sendMessage(sender, to, message); }; async function sendMessage(sender, channel, message) { @@ -42,6 +42,7 @@ module.exports = Self => { return sendAuth(uri, { 'channel': channel, 'avatar': avatar, + 'alias': sender.nickname, 'text': message }).catch(async error => { if (error.statusCode === 401 && !this.resendAttempted) { From d481b0c71fd3e16320fa2c8c71ba93ac9848f267 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 11 Feb 2020 09:00:06 +0100 Subject: [PATCH 3/4] 2093 - Mention destinatary sending to department room --- back/methods/chat/sendCheckingPresence.js | 6 +++--- back/methods/chat/spec/sendCheckingPresence.spec.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index ac5836af3..3af0212c3 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -41,11 +41,11 @@ module.exports = Self => { }); const department = workerDepartment.department(); const channelName = department.chatName; - room = `#${channelName}`; - if (channelName) + if (channelName) { + message = `@${account.name} => ${message}`; room = `#${channelName}`; - else room = `@${account.name}`; + } else room = `@${account.name}`; } return Self.send(ctx, room, message); diff --git a/back/methods/chat/spec/sendCheckingPresence.spec.js b/back/methods/chat/spec/sendCheckingPresence.spec.js index 12a163962..1523cb1d0 100644 --- a/back/methods/chat/spec/sendCheckingPresence.spec.js +++ b/back/methods/chat/spec/sendCheckingPresence.spec.js @@ -38,7 +38,7 @@ describe('chat sendCheckingPresence()', () => { expect(response.statusCode).toEqual(200); expect(response.message).toEqual('Fake notification sent'); - expect(chatModel.send).toHaveBeenCalledWith(ctx, '#cooler', 'I changed something'); + expect(chatModel.send).toHaveBeenCalledWith(ctx, '#cooler', '@HankPym => I changed something'); }); it(`should call to send() method with the worker username when the worker is working`, async() => { From df21309e0a5734bec3a814a946ea106d8eb8b294 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 11 Feb 2020 09:14:40 +0100 Subject: [PATCH 4/4] Changes --- back/methods/chat/sendCheckingPresence.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 3af0212c3..70b4da58f 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -30,10 +30,7 @@ module.exports = Self => { const query = `SELECT worker_isWorking(?) isWorking`; const [result] = await Self.rawSql(query, [workerId]); - let room; - if (result.isWorking) - room = `@${account.name}`; - else { + if (!result.isWorking) { const workerDepartment = await models.WorkerDepartment.findById(workerId, { include: { relation: 'department' @@ -42,12 +39,10 @@ module.exports = Self => { const department = workerDepartment.department(); const channelName = department.chatName; - if (channelName) { - message = `@${account.name} => ${message}`; - room = `#${channelName}`; - } else room = `@${account.name}`; + if (channelName) + return Self.send(ctx, `#${channelName}`, `@${account.name} => ${message}`); } - return Self.send(ctx, room, message); + return Self.send(ctx, `@${account.name}`, message); }; };