diff --git a/apps/meteor/app/livechat/server/hooks/markRoomResponded.ts b/apps/meteor/app/livechat/server/hooks/markRoomResponded.ts index 19b18e0559e4..bed3dfa62693 100644 --- a/apps/meteor/app/livechat/server/hooks/markRoomResponded.ts +++ b/apps/meteor/app/livechat/server/hooks/markRoomResponded.ts @@ -23,13 +23,13 @@ callbacks.add( // Return YYYY-MM from moment const monthYear = moment().format('YYYY-MM'); - if (!(await LivechatVisitors.isVisitorActiveOnPeriod(room.v._id, monthYear))) { - await Promise.all([ - LivechatVisitors.markVisitorActiveForPeriod(room.v._id, monthYear), - LivechatRooms.markVisitorActiveForPeriod(room._id, monthYear), - ]); + const isVisitorActive = await LivechatVisitors.isVisitorActiveOnPeriod(room.v._id, monthYear); + if (!isVisitorActive) { + await LivechatVisitors.markVisitorActiveForPeriod(room.v._id, monthYear); } + await LivechatRooms.markVisitorActiveForPeriod(room._id, monthYear); + if (room.responseBy) { await LivechatRooms.setAgentLastMessageTs(room._id); } diff --git a/apps/meteor/server/models/raw/LivechatRooms.ts b/apps/meteor/server/models/raw/LivechatRooms.ts index fa0b988e4462..40f6de9a2fba 100644 --- a/apps/meteor/server/models/raw/LivechatRooms.ts +++ b/apps/meteor/server/models/raw/LivechatRooms.ts @@ -2458,11 +2458,8 @@ export class LivechatRoomsRaw extends BaseRaw implements ILive }; const update = { - $push: { - 'v.activity': { - $each: [period], - $slice: -12, - }, + $addToSet: { + 'v.activity': period, }, };