diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index ac5836af3..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' @@ -41,13 +38,11 @@ module.exports = Self => { }); const department = workerDepartment.department(); const channelName = department.chatName; - room = `#${channelName}`; if (channelName) - room = `#${channelName}`; - else room = `@${account.name}`; + return Self.send(ctx, `#${channelName}`, `@${account.name} => ${message}`); } - return Self.send(ctx, room, message); + return Self.send(ctx, `@${account.name}`, 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() => {