Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
emile-bex committed Oct 30, 2023
2 parents c616850 + 20e656d commit 2b80131
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "linkedout-backend",
"version": "2.15.5",
"version": "2.15.6",
"license": "ISC",
"engines": {
"node": "16.x"
Expand Down
50 changes: 29 additions & 21 deletions src/external-services/salesforce/salesforce.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,15 @@ export class SalesforceService {
if ((err as SalesforceError).errorCode === ErrorCodes.NOT_FOUND) {
return leadSfIdToUpdate;
}
if (
(err as SalesforceError).errorCode === ErrorCodes.UNABLE_TO_LOCK_ROW
) {
return (await this.updateLead(
leadSfIdToUpdate,
lead,
recordType
)) as string;
}
}
}
return leadSfId;
Expand Down Expand Up @@ -1010,28 +1019,28 @@ export class SalesforceService {
autreSource: 'Formulaire_Sourcing_Page_Travailler',
} as const;

if (infoCo) {
try {
const leadId = (await this.createCandidateLead(leadToCreate)) as string;
try {
const leadId = (await this.createCandidateLead(leadToCreate)) as string;
if (infoCo) {
await this.createCampaignMemberInfoCo({ leadId }, infoCo);
return leadId;
} catch (err) {
if (
(err as SalesforceError).errorCode ===
ErrorCodes.CANNOT_UPDATE_CONVERTED_LEAD ||
(err as SalesforceError).errorCode ===
ErrorCodes.FIELD_INTEGRITY_EXCEPTION
) {
const contactSfId = await this.findContact(email);
await this.createCampaignMemberInfoCo(
{ contactId: contactSfId },
infoCo
);
return contactSfId;
}
console.error(err);
throw err;
}
} catch (err) {
if (
(err as SalesforceError).errorCode ===
ErrorCodes.CANNOT_UPDATE_CONVERTED_LEAD ||
(err as SalesforceError).errorCode ===
ErrorCodes.FIELD_INTEGRITY_EXCEPTION
) {
const contactSfId = await this.findContact(email);
await this.createCampaignMemberInfoCo(
{ contactId: contactSfId },
infoCo
);
return contactSfId;
}
console.error(err);
throw err;
}
}

Expand Down Expand Up @@ -1073,9 +1082,8 @@ export class SalesforceService {
await this.findOrCreateCampaignMember(leadOrContactId, infoCoId);
} catch (err) {
if (
(err as SalesforceError).errorCode !== ErrorCodes.UNABLE_TO_LOCK_ROW
(err as SalesforceError).errorCode === ErrorCodes.UNABLE_TO_LOCK_ROW
) {
await asyncTimeout(1000);
await this.findOrCreateCampaignMember(leadOrContactId, infoCoId);
}
console.error(err);
Expand Down

0 comments on commit 2b80131

Please sign in to comment.