Skip to content

Commit

Permalink
chore: create getNotResponseByRoomIdUpdateQuery method (#33021)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogarim authored Aug 9, 2024
1 parent 7fc1d3e commit 9f50aaf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
4 changes: 2 additions & 2 deletions apps/meteor/app/livechat/server/hooks/markRoomNotResponded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,7 +21,7 @@ callbacks.add(
return message;
}

await LivechatRooms.setNotResponseByRoomId(room._id);
LivechatRooms.getNotResponseByRoomIdUpdateQuery(roomUpdater);

return message;
},
Expand Down
19 changes: 4 additions & 15 deletions apps/meteor/server/models/raw/LivechatRooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1983,21 +1983,10 @@ export class LivechatRoomsRaw extends BaseRaw<IOmnichannelRoom> implements ILive
return updater;
}

setNotResponseByRoomId(roomId: string) {
return this.updateOne(
{
_id: roomId,
t: 'l',
},
{
$set: {
waitingResponse: true,
},
$unset: {
responseBy: 1,
},
},
);
getNotResponseByRoomIdUpdateQuery(updater: Updater<IOmnichannelRoom> = this.getUpdater()) {
updater.set('waitingResponse', true);
updater.unset('responseBy');
return updater;
}

getAgentLastMessageTsUpdateQuery(updater: Updater<IOmnichannelRoom> = this.getUpdater()) {
Expand Down
2 changes: 1 addition & 1 deletion packages/model-typings/src/models/ILivechatRoomsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export interface ILivechatRoomsModel extends IBaseModel<IOmnichannelRoom> {
responseBy: IOmnichannelRoom['responseBy'],
updater?: Updater<IOmnichannelRoom>,
): Updater<IOmnichannelRoom>;
setNotResponseByRoomId(roomId: string): Promise<UpdateResult>;
getNotResponseByRoomIdUpdateQuery(updater: Updater<IOmnichannelRoom>): Updater<IOmnichannelRoom>;
getAgentLastMessageTsUpdateQuery(updater?: Updater<IOmnichannelRoom>): Updater<IOmnichannelRoom>;
getAnalyticsUpdateQueryByRoomId(
room: IOmnichannelRoom,
Expand Down

0 comments on commit 9f50aaf

Please sign in to comment.