Skip to content
Snippets Groups Projects
Unverified Commit b2ad88fe authored by Murtaza Patrawala's avatar Murtaza Patrawala Committed by GitHub
Browse files

Regression: Omni-chats not getting routed automatically to bots (#26267)

parent 86d3726f
No related branches found
No related tags found
No related merge requests found
......@@ -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',
......
......@@ -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) {
......@@ -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,
......
......@@ -239,7 +239,7 @@ export class Users extends Base {
return [];
}
getNextBotAgent(ignoreAgentId) {
async getNextBotAgent(ignoreAgentId) {
// TODO: Create class Agent
const query = {
roles: {
......@@ -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,
......
......@@ -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'] },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment