diff --git a/apps/meteor/app/livechat/server/hooks/markRoomNotResponded.ts b/apps/meteor/app/livechat/server/hooks/markRoomNotResponded.ts index 23131cee60a28..01d3014f1c277 100644 --- a/apps/meteor/app/livechat/server/hooks/markRoomNotResponded.ts +++ b/apps/meteor/app/livechat/server/hooks/markRoomNotResponded.ts @@ -5,7 +5,7 @@ import { callbacks } from '../../../../lib/callbacks'; callbacks.add( 'afterOmnichannelSaveMessage', - async (message, { room }) => { + (message, { room, roomUpdater }) => { // skips this callback if the message was edited if (!message || isEditedMessage(message)) { return message; @@ -21,7 +21,7 @@ callbacks.add( return message; } - await LivechatRooms.setNotResponseByRoomId(room._id); + LivechatRooms.getNotResponseByRoomIdUpdateQuery(roomUpdater); return message; }, diff --git a/apps/meteor/server/models/raw/LivechatRooms.ts b/apps/meteor/server/models/raw/LivechatRooms.ts index f3ddb73a7b923..b588b48cef5b6 100644 --- a/apps/meteor/server/models/raw/LivechatRooms.ts +++ b/apps/meteor/server/models/raw/LivechatRooms.ts @@ -1983,21 +1983,10 @@ export class LivechatRoomsRaw extends BaseRaw implements ILive return updater; } - setNotResponseByRoomId(roomId: string) { - return this.updateOne( - { - _id: roomId, - t: 'l', - }, - { - $set: { - waitingResponse: true, - }, - $unset: { - responseBy: 1, - }, - }, - ); + getNotResponseByRoomIdUpdateQuery(updater: Updater = this.getUpdater()) { + updater.set('waitingResponse', true); + updater.unset('responseBy'); + return updater; } getAgentLastMessageTsUpdateQuery(updater: Updater = this.getUpdater()) { diff --git a/packages/model-typings/src/models/ILivechatRoomsModel.ts b/packages/model-typings/src/models/ILivechatRoomsModel.ts index a6ed74d0b19a6..babfa4ea21656 100644 --- a/packages/model-typings/src/models/ILivechatRoomsModel.ts +++ b/packages/model-typings/src/models/ILivechatRoomsModel.ts @@ -212,7 +212,7 @@ export interface ILivechatRoomsModel extends IBaseModel { responseBy: IOmnichannelRoom['responseBy'], updater?: Updater, ): Updater; - setNotResponseByRoomId(roomId: string): Promise; + getNotResponseByRoomIdUpdateQuery(updater: Updater): Updater; getAgentLastMessageTsUpdateQuery(updater?: Updater): Updater; getAnalyticsUpdateQueryByRoomId( room: IOmnichannelRoom,