From 7b958ba929c3a44a6b0114be3442f917351c38d1 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 11 Feb 2020 09:14:40 +0100 Subject: [PATCH] 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); }; };