diff --git a/apps/meteor/app/livechat/server/lib/departmentsLib.ts b/apps/meteor/app/livechat/server/lib/departmentsLib.ts index fdc85105ab07..7dec370768f0 100644 --- a/apps/meteor/app/livechat/server/lib/departmentsLib.ts +++ b/apps/meteor/app/livechat/server/lib/departmentsLib.ts @@ -126,6 +126,10 @@ export async function saveDepartment( await updateDepartmentAgents(departmentDB._id, departmentAgents, departmentDB.enabled); } + if (department?.enabled !== departmentData.enabled) { + void notifyOnLivechatDepartmentAgentChangedByDepartmentId(departmentDB._id, department ? 'updated' : 'inserted'); + } + // Disable event if (department?.enabled && !departmentDB?.enabled) { await callbacks.run('livechat.afterDepartmentDisabled', departmentDB); diff --git a/apps/meteor/server/models/raw/LivechatDepartment.ts b/apps/meteor/server/models/raw/LivechatDepartment.ts index 5ab3ab52be09..7e318ad33935 100644 --- a/apps/meteor/server/models/raw/LivechatDepartment.ts +++ b/apps/meteor/server/models/raw/LivechatDepartment.ts @@ -17,7 +17,6 @@ import type { } from 'mongodb'; import { BaseRaw } from './BaseRaw'; -import { notifyOnLivechatDepartmentAgentChangedByDepartmentId } from '../../../app/lib/server/lib/notifyListener'; export class LivechatDepartmentRaw extends BaseRaw implements ILivechatDepartmentModel { constructor(db: Db, trash?: Collection>) { @@ -260,7 +259,6 @@ export class LivechatDepartmentRaw extends BaseRaw implemen if (current?.enabled !== data.enabled) { await LivechatDepartmentAgents.setDepartmentEnabledByDepartmentId(_id, data.enabled); - void notifyOnLivechatDepartmentAgentChangedByDepartmentId(_id, current ? 'updated' : 'inserted'); } const latestDept = await this.findOneById(_id);