Merge branch '2093-chat_mention_destinatary' of verdnatura/salix into dev
gitea/salix/dev This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2020-02-11 08:24:54 +00:00 committed by Gitea
commit 5313ffff2e
2 changed files with 4 additions and 9 deletions

View File

@ -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);
};
};

View File

@ -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() => {