Skip to content

Commit

Permalink
Regression: Omni-chats not getting routed automatically to bots (#26267)
Browse files Browse the repository at this point in the history
  • Loading branch information
murtaza98 authored Jul 15, 2022
1 parent 86d3726 commit b2ad88f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions apps/meteor/app/livechat/server/hooks/beforeDelegateAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ callbacks.add(
}

if (department) {
return LivechatDepartmentAgents.getNextBotForDepartment(department);
return Promise.await(LivechatDepartmentAgents.getNextBotForDepartment(department));
}

return Users.getNextBotAgent();
return Promise.await(Users.getNextBotAgent());
},
callbacks.priority.HIGH,
'livechat-before-delegate-agent',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class LivechatDepartmentAgents extends Base {
return this.find(query);
}

getNextBotForDepartment(departmentId, ignoreAgentId) {
async getNextBotForDepartment(departmentId, ignoreAgentId) {
const agents = this.findByDepartmentId(departmentId).fetch();

if (agents.length === 0) {
Expand Down Expand Up @@ -184,7 +184,7 @@ export class LivechatDepartmentAgents extends Base {
},
};

const bot = this.model.rawCollection().findOneAndUpdate(query, update, { sort, returnNewDocument: 'after' });
const bot = await this.model.rawCollection().findOneAndUpdate(query, update, { sort, returnNewDocument: 'after' });
if (bot && bot.value) {
return {
agentId: bot.value.agentId,
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/models/server/models/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class Users extends Base {
return [];
}

getNextBotAgent(ignoreAgentId) {
async getNextBotAgent(ignoreAgentId) {
// TODO: Create class Agent
const query = {
roles: {
Expand All @@ -259,7 +259,7 @@ export class Users extends Base {
},
};

const user = this.model.rawCollection().findOneAndUpdate(query, update, { sort, returnDocument: 'after' });
const user = await this.model.rawCollection().findOneAndUpdate(query, update, { sort, returnDocument: 'after' });
if (user && user.value) {
return {
agentId: user.value._id,
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/lib/callbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ type ChainedCallbackSignatures = {
};
'livechat.applySimultaneousChatRestrictions': (_: undefined, params: { departmentId?: ILivechatDepartmentRecord['_id'] }) => undefined;
'livechat.beforeCloseRoom': (params: { room: IRoom; options: unknown }) => { room: IRoom; options: unknown };
'livechat.beforeDelegateAgent': (agent: ILivechatAgent, params: { department?: ILivechatDepartmentRecord }) => ILivechatAgent;
'livechat.beforeDelegateAgent': (agent: ILivechatAgent, params: { department?: ILivechatDepartmentRecord }) => ILivechatAgent | null;
'livechat.applyDepartmentRestrictions': (
query: FilterOperators<ILivechatDepartmentRecord>,
params: { userId: IUser['_id'] },
Expand Down

0 comments on commit b2ad88f

Please sign in to comment.