Migration and model for triggers.

Not tested.
This commit is contained in:
Tomas Bures 2018-08-03 21:37:46 +05:30
parent 7b46c4b4b0
commit ffc26a4836
11 changed files with 353 additions and 40 deletions

View file

@ -40,9 +40,37 @@ const CampaignStatus = {
MAA: 6
};
const campaignOverridables = ['from_name', 'from_email', 'reply_to', 'subject'];
function getSendConfigurationPermissionRequiredForSend(campaign, sendConfiguration) {
let allowedOverride = false;
let disallowedOverride = false;
for (const overridable of campaignOverridables) {
if (campaign[overridable + '_override'] !== null) {
if (sendConfiguration[overridable + '_overridable']) {
allowedOverride = true;
} else {
disallowedOverride = true;
}
}
}
let requiredPermission = 'send';
if (allowedOverride) {
requiredPermission = 'sendWithAllowedOverrides';
}
if (disallowedOverride) {
requiredPermission = 'sendWithAnyOverrides';
}
return requiredPermission;
}
module.exports = {
CampaignSource,
CampaignType,
CampaignStatus
CampaignStatus,
campaignOverridables,
getSendConfigurationPermissionRequiredForSend
};

48
shared/triggers.js Normal file
View file

@ -0,0 +1,48 @@
'use strict';
const Entity = {
SUBSCRIPTION: 'subscription',
CAMPAIGN: 'campaign'
};
const Action = {
[Entity.SUBSCRIPTION]: {
CREATED: 'created',
LATEST_OPEN: 'latest_open',
LATEST_CLICK: 'latest_click'
},
[Entity.CAMPAIGN]: {
DELIVERED: 'delivered',
OPENED: 'opened',
CLICKED: 'clicked',
NOT_OPENED: 'not_opened',
NOT_CLICKED: 'not_clicked'
}
};
const EntityVals = {
subscription: 'SUBSCRIPTION',
campaign: 'CAMPAIGN'
};
const ActionVals = {
[Entity.SUBSCRIPTION]: {
created: 'CREATED',
latest_open: 'LATEST_OPEN',
latest_click: 'LATEST_CLICK'
},
[Entity.CAMPAIGN]: {
delivered: 'DELIVERED',
opened: 'OPENED',
clicked: 'CLICKED',
not_opened: 'NOT_OPENED',
not_clicked: 'NOT_CLICKED'
}
};
module.exports = {
Entity,
Action,
EntityVals,
ActionVals
};