Skip to content

Commit

Permalink
fix merge of array fields
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-lehnen-rc committed Oct 22, 2024
1 parent 04e7f06 commit c11a62a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions apps/meteor/app/livechat/server/lib/ContactMerger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ export class ContactMerger {

// Phones, Emails and Channels are simply added to the contact's existing list
const dataToAdd: UpdateFilter<ILivechatContact>['$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<ILivechatContact> = {
Expand Down

0 comments on commit c11a62a

Please sign in to comment.