Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release production #803

Merged
merged 4 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/editor/src/js/vue/components/esp/esp-send-mail.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ const EspComponent = Vue.component('EspForm', {
.catch((error) => {
// handle error
console.log(error);

/*
If the campaign for this profile should exist but was not found on DSC,
Then it was probably deleted on DSC's side.
So we allow the user to create a new one
*/
if(error.response.status === 404) {
this.type = SEND_MODE.CREATION;
this.fetchProfileData(message);
return;
}

this.vm.notifier.error(this.vm.t('error-server'));
})
.finally(() => {
Expand Down
15 changes: 14 additions & 1 deletion packages/server/esp/dsc/dscProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ const mailingService = require('../../mailing/mailing.service.js');
const ERROR_CODES = require('../../constant/error-codes.js');
const config = require('../../node.config.js');
const axios = require('../../config/axios');
const { InternalServerError, Conflict, BadRequest } = require('http-errors');
const {
InternalServerError,
Conflict,
BadRequest,
NotFound,
} = require('http-errors');

class DscProvider {
constructor({ apiKey, ...data }) {
Expand Down Expand Up @@ -85,6 +90,10 @@ class DscProvider {
throw new BadRequest(message);
}

if (status === 409) {
throw new Conflict(message);
}

// Log the error and throw a generic error if it doesn't match specific cases
logger.error('Error in API call:', error);
throw new Error('An error occurred while communicating with the API.');
Expand Down Expand Up @@ -124,6 +133,10 @@ class DscProvider {
} catch (e) {
logger.error({ error: e });

if (e?.status === 404) {
throw new NotFound('Campaign not found on DSC');
}

throw e;
}
}
Expand Down
8 changes: 7 additions & 1 deletion packages/server/profile/profile.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,13 @@ async function sendEspCampaign({
const { subject, campaignMailName, planification } = espSendingMailData;
const profile = await findOne(profileId);

await checkIfMailAlreadySentToProfile({ profileId, mailingId });
/*
For DSC, creating a new campaign from the same profile is allowed
if the campaign was deleted on DSC's side
*/
if (type !== 'DSC') {
await checkIfMailAlreadySentToProfile({ profileId, mailingId });
}

const {
apiKey,
Expand Down
Loading