Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Await promise to handle error when attempting to transfer a room #23739

Merged
merged 1 commit into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/livechat/server/lib/Livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ export const Livechat = {
const user = Users.findOneById(userId);
const { _id, username, name } = user;
const transferredBy = normalizeTransferredByData({ _id, username, name }, room);
this.transfer(room, guest, { roomId: room._id, transferredBy, departmentId: guest.department });
Promise.await(this.transfer(room, guest, { roomId: room._id, transferredBy, departmentId: guest.department }));
});
},

Expand Down
20 changes: 15 additions & 5 deletions app/livechat/server/lib/stream/agentStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { Meteor } from 'meteor/meteor';

import { Livechat } from '../Livechat';
import { settings } from '../../../../settings/server';
import { Logger } from '../../../../logger/server';

const logger = new Logger('AgentStatusWatcher');

export let monitorAgents = false;
let actionTimeout = 60000;
Expand Down Expand Up @@ -64,12 +67,19 @@ export const onlineAgents = {
onlineAgents.users.delete(userId);
onlineAgents.queue.delete(userId);

if (action === 'close') {
return Livechat.closeOpenChats(userId, comment);
}
try {
if (action === 'close') {
return Livechat.closeOpenChats(userId, comment);
}

if (action === 'forward') {
return Livechat.forwardOpenChats(userId);
if (action === 'forward') {
return Livechat.forwardOpenChats(userId);
}
} catch (e) {
logger.error({
msg: `Cannot perform action ${ action }`,
err: e,
});
}
}),
};