import { CannedResponse } from '@rocket.chat/models'; import { callbacks } from '../../../../server/lib/callbacks'; import notifications from '../../../../server/lib/notifications/core/lib/Notifications'; callbacks.add( 'livechat.removeAgentDepartment', async (options: Record): Promise => { const { departmentId, agentsId } = options; await CannedResponse.findByDepartmentId(departmentId, { projection: { _id: 1 } }).forEach((response: any) => { const { _id } = response; notifications.streamCannedResponses.emit('canned-responses', { type: 'removed', _id }, { agentsId }); }); return options; }, callbacks.priority.HIGH, 'canned-responses-on-remove-agent-department', );