Migration and model for triggers.
Not tested.
This commit is contained in:
parent
7b46c4b4b0
commit
ffc26a4836
11 changed files with 353 additions and 40 deletions
|
@ -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
48
shared/triggers.js
Normal 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
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue