Skip to content

Commit

Permalink
Await promise to handle error when attempting to transfer a room (#23739
Browse files Browse the repository at this point in the history
)
  • Loading branch information
KevLehman authored Nov 18, 2021
1 parent c54ef38 commit bc91e46
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
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,
});
}
}),
};

0 comments on commit bc91e46

Please sign in to comment.