From c11a62a666210af7b4b92898c00cc47dffc11b92 Mon Sep 17 00:00:00 2001 From: Pierre Date: Tue, 22 Oct 2024 13:17:50 -0300 Subject: [PATCH] fix merge of array fields --- apps/meteor/app/livechat/server/lib/ContactMerger.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/meteor/app/livechat/server/lib/ContactMerger.ts b/apps/meteor/app/livechat/server/lib/ContactMerger.ts index 9347c8d0409d..d944a013871e 100644 --- a/apps/meteor/app/livechat/server/lib/ContactMerger.ts +++ b/apps/meteor/app/livechat/server/lib/ContactMerger.ts @@ -268,10 +268,10 @@ export class ContactMerger { // Phones, Emails and Channels are simply added to the contact's existing list const dataToAdd: UpdateFilter['$addToSet'] = { - ...(newPhones.length ? { phones: newPhones.map((phoneNumber) => ({ phoneNumber })) } : {}), - ...(newEmails.length ? { emails: newEmails.map((address) => ({ address })) } : {}), - ...(newChannels.length ? { channels: newChannels } : {}), - ...(allConflicts.length ? { conflictingFields: allConflicts } : {}), + ...(newPhones.length ? { phones: { $each: newPhones.map((phoneNumber) => ({ phoneNumber })) } } : {}), + ...(newEmails.length ? { emails: { $each: newEmails.map((address) => ({ address })) } } : {}), + ...(newChannels.length ? { channels: { $each: newChannels } } : {}), + ...(allConflicts.length ? { conflictingFields: { $each: allConflicts } } : {}), }; const updateData: UpdateFilter = {