Skip to content

Commit

Permalink
[FIX] Omnichannel inquiries being updated even if not needed (#26692)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman authored and sampaiodiego committed Aug 29, 2022
1 parent 29fb34b commit 0ba075b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/meteor/server/models/raw/LivechatInquiry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ export class LivechatInquiryRaw extends BaseRaw<ILivechatInquiryRecord> implemen
}

async unlockAll(): Promise<UpdateResult | Document> {
return this.updateMany({}, { $unset: { locked: 1, lockedAt: 1 } });
return this.updateMany(
{ $or: [{ lockedAt: { $exists: true } }, { locked: { $exists: true } }] },
{ $unset: { locked: 1, lockedAt: 1 } },
);
}
}
11 changes: 11 additions & 0 deletions apps/meteor/server/modules/listeners/listeners.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ export class ListenersModule {
});
}

// Don't do notifications for updating inquiries when the only thing changing is the queue metadata
if (
clientAction === 'updated' &&
diff?.hasOwnProperty('lockedAt') &&
diff?.hasOwnProperty('locked') &&
diff?.hasOwnProperty('_updatedAt') &&
Object.keys(diff).length === 3
) {
return;
}

notifications.streamLivechatQueueData.emitWithoutBroadcast(inquiry._id, {
...inquiry,
clientAction,
Expand Down

0 comments on commit 0ba075b

Please sign in to comment.