abmp-npm 2.0.24 → 2.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -31,7 +31,7 @@ async function findMemberByWixDataId(memberId) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
async function createContactAndMemberIfNew(memberData) {
|
|
34
|
+
async function createContactAndMemberIfNew(memberData, allowDuplicates = false) {
|
|
35
35
|
if (!memberData) {
|
|
36
36
|
throw new Error('Member data is required');
|
|
37
37
|
}
|
|
@@ -47,7 +47,9 @@ async function createContactAndMemberIfNew(memberData) {
|
|
|
47
47
|
const needsWixContact = !memberData.wixContactId;
|
|
48
48
|
const [newWixMemberId, newWixContactId] = await Promise.all([
|
|
49
49
|
needsWixMember ? createSiteMember(toCreateMemberData) : Promise.resolve(null),
|
|
50
|
-
needsWixContact
|
|
50
|
+
needsWixContact
|
|
51
|
+
? createSiteContact(toCreateMemberData, allowDuplicates)
|
|
52
|
+
: Promise.resolve(null),
|
|
51
53
|
]);
|
|
52
54
|
let memberDataWithContactId = {
|
|
53
55
|
...memberData,
|
|
@@ -562,7 +562,7 @@ const scheduleCreateContactsFromMembers = async () => {
|
|
|
562
562
|
const createContactsFromMembers = async data => {
|
|
563
563
|
const { chunk, chunkIndex } = data;
|
|
564
564
|
console.log(`Creating contacts from ${chunk.length} members in chunk ${chunkIndex}`);
|
|
565
|
-
const createPromises = chunk.map(member => createContactAndMemberIfNew(member));
|
|
565
|
+
const createPromises = chunk.map(member => createContactAndMemberIfNew(member, true));
|
|
566
566
|
const createResults = await Promise.all(createPromises);
|
|
567
567
|
console.log(
|
|
568
568
|
`Created ${createResults.length} contacts from ${chunk.length} members in chunk ${chunkIndex}`
|