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
|
@ -38,6 +38,7 @@ const accountRest = require('./routes/rest/account');
|
|||
const reportTemplatesRest = require('./routes/rest/report-templates');
|
||||
const reportsRest = require('./routes/rest/reports');
|
||||
const campaignsRest = require('./routes/rest/campaigns');
|
||||
const triggersRest = require('./routes/rest/triggers');
|
||||
const listsRest = require('./routes/rest/lists');
|
||||
const formsRest = require('./routes/rest/forms');
|
||||
const fieldsRest = require('./routes/rest/fields');
|
||||
|
@ -279,6 +280,7 @@ function createApp(trusted) {
|
|||
app.use('/rest', usersRest);
|
||||
app.use('/rest', accountRest);
|
||||
app.use('/rest', campaignsRest);
|
||||
app.use('/rest', triggersRest);
|
||||
app.use('/rest', listsRest);
|
||||
app.use('/rest', formsRest);
|
||||
app.use('/rest', fieldsRest);
|
||||
|
|
|
@ -41,8 +41,8 @@ import axios from '../lib/axios';
|
|||
import styles from "../lib/styles.scss";
|
||||
import {getUrl} from "../lib/urls";
|
||||
import {
|
||||
campaignOverridables,
|
||||
CampaignSource,
|
||||
CampaignStatus,
|
||||
CampaignType
|
||||
} from "../../../shared/campaigns";
|
||||
import moment from 'moment';
|
||||
|
@ -50,8 +50,6 @@ import {getMailerTypes} from "../send-configurations/helpers";
|
|||
import {ResourceType} from "../lib/mosaico";
|
||||
import {getCampaignTypeLabels} from "./helpers";
|
||||
|
||||
const overridables = ['from_name', 'from_email', 'reply_to', 'subject'];
|
||||
|
||||
@translate()
|
||||
@withForm
|
||||
@withPageHelpers
|
||||
|
@ -160,7 +158,7 @@ export default class CUD extends Component {
|
|||
|
||||
data.useSegmentation = !!data.segment;
|
||||
|
||||
for (const overridable of overridables) {
|
||||
for (const overridable of campaignOverridables) {
|
||||
data[overridable + '_overriden'] = !!data[overridable + '_override'];
|
||||
}
|
||||
|
||||
|
@ -169,7 +167,7 @@ export default class CUD extends Component {
|
|||
|
||||
} else {
|
||||
const data = {};
|
||||
for (const overridable of overridables) {
|
||||
for (const overridable of campaignOverridables) {
|
||||
data[overridable + '_override'] = '';
|
||||
data[overridable + '_overriden'] = false;
|
||||
}
|
||||
|
@ -348,7 +346,7 @@ export default class CUD extends Component {
|
|||
data.data.feedUrl = data.data_feedUrl;
|
||||
}
|
||||
|
||||
for (const overridable of overridables) {
|
||||
for (const overridable of campaignOverridables) {
|
||||
if (!data[overridable + '_overriden']) {
|
||||
data[overridable + '_override'] = null;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ import styles from "../lib/styles.scss";
|
|||
import {getUrl} from "../lib/urls";
|
||||
import {ResourceType} from "../lib/mosaico";
|
||||
|
||||
const overridables = ['from_name', 'from_email', 'reply_to', 'subject'];
|
||||
|
||||
@translate()
|
||||
@withForm
|
||||
|
|
|
@ -208,7 +208,7 @@ permissions=["view", "edit", "delete", "share", "createNamespace", "createList",
|
|||
sendConfiguration=["viewPublic", "viewPrivate", "edit", "delete", "share", "sendWithoutOverrides", "sendWithAllowedOverrides", "sendWithAnyOverrides"]
|
||||
list=["view", "edit", "delete", "share", "viewFields", "manageFields", "viewSubscriptions", "manageSubscriptions", "viewSegments", "manageSegments"]
|
||||
customForm=["view", "edit", "delete", "share"]
|
||||
campaign=["view", "edit", "delete", "share", "viewFiles", "manageFiles", "viewAttachments", "manageAttachments", "send", "viewStats"]
|
||||
campaign=["view", "edit", "delete", "share", "viewFiles", "manageFiles", "viewAttachments", "manageAttachments", "viewTriggers", "manageTriggers", "send", "viewStats"]
|
||||
template=["view", "edit", "delete", "share", "viewFiles", "manageFiles"]
|
||||
report=["view", "edit", "delete", "share", "execute", "viewContent", "viewOutput"]
|
||||
reportTemplate=["view", "edit", "delete", "share", "execute"]
|
||||
|
@ -233,7 +233,7 @@ permissions=["view", "edit", "delete", "share"]
|
|||
[roles.campaign.master]
|
||||
name="Master"
|
||||
description="All permissions"
|
||||
permissions=["view", "edit", "delete", "share", "viewFiles", "manageFiles", "viewAttachments", "manageAttachments", "send", "viewStats"]
|
||||
permissions=["view", "edit", "delete", "share", "viewFiles", "manageFiles", "viewAttachments", "manageAttachments", "viewTriggers", "manageTriggers", "send", "viewStats"]
|
||||
|
||||
[roles.template.master]
|
||||
name="Master"
|
||||
|
@ -257,6 +257,7 @@ permissions=["view", "edit", "delete", "share", "viewFiles", "manageFiles"]
|
|||
|
||||
|
||||
|
||||
|
||||
[roles.global.editor]
|
||||
name="Editor"
|
||||
description="XXX"
|
||||
|
@ -279,6 +280,11 @@ reportTemplate=[]
|
|||
namespace=["view", "edit", "delete"]
|
||||
mosaicoTemplate=[]
|
||||
|
||||
[roles.sendConfiguration.editor]
|
||||
name="Editor"
|
||||
description="XXX"
|
||||
permissions=[]
|
||||
|
||||
[roles.list.editor]
|
||||
name="Editor"
|
||||
description="XXX"
|
||||
|
@ -314,8 +320,3 @@ name="Editor"
|
|||
description="XXX"
|
||||
permissions=[]
|
||||
|
||||
[roles.sendConfiguration.editor]
|
||||
name="Editor"
|
||||
description="XXX"
|
||||
permissions=[]
|
||||
|
||||
|
|
|
@ -10,8 +10,10 @@ const shares = require('./shares');
|
|||
const namespaceHelpers = require('../lib/namespace-helpers');
|
||||
const files = require('./files');
|
||||
const templates = require('./templates');
|
||||
const { CampaignSource, CampaignType} = require('../shared/campaigns');
|
||||
const { CampaignSource, CampaignType, getSendConfigurationPermissionRequiredForSend} = require('../shared/campaigns');
|
||||
const segments = require('./segments');
|
||||
const sendConfigurations = require('./send-configurations');
|
||||
const triggers = require('./triggers');
|
||||
|
||||
const allowedKeysCommon = ['name', 'description', 'list', 'segment', 'namespace',
|
||||
'send_configuration', 'from_name_override', 'from_email_override', 'reply_to_override', 'subject_override', 'data', 'click_tracking_disabled', 'open_tracking_disabled'];
|
||||
|
@ -293,14 +295,26 @@ async function remove(context, id) {
|
|||
|
||||
// FIXME - deal with deletion of dependent entities (files)
|
||||
|
||||
await triggers.removeAllByCampaignIdTx(tx, context, id);
|
||||
|
||||
await tx('campaigns').where('id', id).del();
|
||||
await knex.schema.dropTableIfExists('campaign__' + id);
|
||||
await knex.schema.dropTableIfExists('campaign_tracker__' + id);
|
||||
});
|
||||
}
|
||||
|
||||
async function enforceSendPermissionTx(tx, context, campaignId) {
|
||||
const campaign = await getByIdTx(tx, context, campaignId, false);
|
||||
const sendConfiguration = await sendConfigurations.getByIdTx(tx, context, campaign.send_configuration, false, false);
|
||||
|
||||
module.exports = {
|
||||
const requiredPermission = getSendConfigurationPermissionRequiredForSend(campaign, sendConfiguration);
|
||||
|
||||
await shares.enforceEntityPermissionTx(tx, context, 'send_configuration', campaign.send_configuration, requiredPermission);
|
||||
await shares.enforceEntityPermissionTx(tx, context, 'campaign', campaignId, requiredPermission);
|
||||
}
|
||||
|
||||
// This is to handle circular dependency with triggers.js
|
||||
Object.assign(module.exports, {
|
||||
Content,
|
||||
hash,
|
||||
listDTAjax,
|
||||
|
@ -309,5 +323,6 @@ module.exports = {
|
|||
getById,
|
||||
create,
|
||||
updateWithConsistencyCheck,
|
||||
remove
|
||||
};
|
||||
remove,
|
||||
enforceSendPermissionTx
|
||||
});
|
|
@ -30,27 +30,31 @@ async function listDTAjax(context, params) {
|
|||
);
|
||||
}
|
||||
|
||||
async function getByIdTx(tx, context, id, withPermissions = true, withPrivateData = true) {
|
||||
let entity;
|
||||
|
||||
if (withPrivateData) {
|
||||
await shares.enforceEntityPermissionTx(tx, context, 'sendConfiguration', id, 'viewPrivate');
|
||||
entity = await tx('send_configurations').where('id', id).first();
|
||||
entity.mailer_settings = JSON.parse(entity.mailer_settings);
|
||||
} else {
|
||||
await shares.enforceEntityPermissionTx(tx, context, 'sendConfiguration', id, 'viewPublic');
|
||||
entity = await tx('send_configurations').where('id', id).select(
|
||||
['id', 'name', 'description', 'from_email', 'from_email_overridable', 'from_name', 'from_name_overridable', 'reply_to', 'reply_to_overridable', 'subject', 'subject_overridable']
|
||||
).first();
|
||||
}
|
||||
|
||||
// note that permissions are optional as as this methods may be used with synthetic admin context
|
||||
if (withPermissions) {
|
||||
entity.permissions = await shares.getPermissionsTx(tx, context, 'sendConfiguration', id);
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
async function getById(context, id, withPermissions = true, withPrivateData = true) {
|
||||
return await knex.transaction(async tx => {
|
||||
let entity;
|
||||
|
||||
if (withPrivateData) {
|
||||
await shares.enforceEntityPermissionTx(tx, context, 'sendConfiguration', id, 'viewPrivate');
|
||||
entity = await tx('send_configurations').where('id', id).first();
|
||||
entity.mailer_settings = JSON.parse(entity.mailer_settings);
|
||||
} else {
|
||||
await shares.enforceEntityPermissionTx(tx, context, 'sendConfiguration', id, 'viewPublic');
|
||||
entity = await tx('send_configurations').where('id', id).select(
|
||||
['id', 'name', 'description', 'from_email', 'from_email_overridable', 'from_name', 'from_name_overridable', 'reply_to', 'reply_to_overridable', 'subject', 'subject_overridable']
|
||||
).first();
|
||||
}
|
||||
|
||||
// note that permissions are optional as as this methods may be used with synthetic admin context
|
||||
if (withPermissions) {
|
||||
entity.permissions = await shares.getPermissionsTx(tx, context, 'sendConfiguration', id);
|
||||
}
|
||||
|
||||
return entity;
|
||||
return await getByIdTx(tx, context, id, withPermissions, withPrivateData);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -130,6 +134,7 @@ module.exports = {
|
|||
MailerType,
|
||||
hash,
|
||||
listDTAjax,
|
||||
getByIdTx,
|
||||
getById,
|
||||
create,
|
||||
updateWithConsistencyCheck,
|
||||
|
|
146
models/triggers.js
Normal file
146
models/triggers.js
Normal file
|
@ -0,0 +1,146 @@
|
|||
'use strict';
|
||||
|
||||
const knex = require('../lib/knex');
|
||||
const hasher = require('node-object-hash')();
|
||||
const { enforce, filterObject } = require('../lib/helpers');
|
||||
const dtHelpers = require('../lib/dt-helpers');
|
||||
const interoperableErrors = require('../shared/interoperable-errors');
|
||||
const shares = require('./shares');
|
||||
const {EntityVals, ActionVals} = require('../shared/triggers');
|
||||
const campaigns = require('./campaigns');
|
||||
|
||||
const allowedKeys = new Set(['name', 'description', 'entity', 'action', 'seconds_after', 'enabled', 'source_campaign']);
|
||||
|
||||
function hash(entity) {
|
||||
return hasher.hash(filterObject(entity, allowedKeys));
|
||||
}
|
||||
|
||||
async function getById(context, campaignId, id) {
|
||||
return await knex.transaction(async tx => {
|
||||
await shares.enforceEntityPermissionTx(tx, context, 'campaign', campaignId, 'viewTriggers');
|
||||
|
||||
const entity = await tx('triggers').where({campaign: campaignId, id}).first();
|
||||
|
||||
return entity;
|
||||
});
|
||||
}
|
||||
|
||||
async function listByCampaignDTAjax(context, campaignId, params) {
|
||||
return await knex.transaction(async tx => {
|
||||
await shares.enforceEntityPermissionTx(tx, context, 'campaign', campaignId, 'viewTriggers');
|
||||
|
||||
return await dtHelpers.ajaxListTx(
|
||||
tx,
|
||||
params,
|
||||
builder => builder
|
||||
.from('triggers')
|
||||
.innerJoin('campaigns', 'campaign.id', 'triggers.campaign')
|
||||
.where('triggers.campaign', campaignId),
|
||||
[ 'triggers.id', 'triggers.name', 'campaign.list', 'triggers.entity', 'triggers.action', 'triggers.source_campaign', 'triggers.enabled' ]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
async function listByListDTAjax(context, listId, params) {
|
||||
return await dtHelpers.ajaxListWithPermissions(
|
||||
context,
|
||||
[{ entityTypeId: 'campaign', requiredOperations: ['view'] }],
|
||||
params,
|
||||
builder => builder
|
||||
.from('triggers')
|
||||
.innerJoin('campaigns', 'campaign.id', 'triggers.campaign')
|
||||
.where('campaign.list', listId),
|
||||
[ 'triggers.id', 'triggers.name', 'trigger.campaign', 'triggers.entity', 'triggers.action', 'triggers.source_campaign', 'triggers.enabled' ]
|
||||
);
|
||||
}
|
||||
|
||||
async function _validateAndPreprocess(tx, context, campaignId, entity) {
|
||||
enforce(Number.isInteger(entity.seconds_after));
|
||||
enforce(entity.seconds_after >= 0, 'Seconds after must not be negative');
|
||||
enforce(entity.entity in EntityVals, 'Invalid entity');
|
||||
enforce(entity.action in ActionVals[entity.entity], 'Invalid action');
|
||||
|
||||
if (entity.entity === Entity.CAMPAIGN) {
|
||||
await shares.enforceEntityPermissionTx(tx, context, 'campaign', entity.source_campaign, 'view');
|
||||
}
|
||||
|
||||
await campaigns.enforceSendPermissionTx(tx, context, campaignId);
|
||||
}
|
||||
|
||||
async function create(context, campaignId, entity) {
|
||||
return await knex.transaction(async tx => {
|
||||
await shares.enforceEntityPermissionTx(tx, context, 'campaign', campaignId, 'manageTriggers');
|
||||
|
||||
await _validateAndPreprocess(tx, context, campaignId, entity);
|
||||
|
||||
const filteredEntity = filterObject(entity, allowedKeys);
|
||||
filteredEntity.campaign = campaignId;
|
||||
|
||||
const ids = await tx('triggers').insert(filteredEntity);
|
||||
const id = ids[0];
|
||||
|
||||
await knex.schema.raw('CREATE TABLE `trigger__' + id + '` (\n' +
|
||||
' `list` int(11) unsigned NOT NULL,\n' +
|
||||
' `subscription` int(11) unsigned NOT NULL,\n' +
|
||||
' `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n' +
|
||||
' PRIMARY KEY (`list`,`subscription`)\n' +
|
||||
') ENGINE=InnoDB DEFAULT CHARSET=utf8;\n');
|
||||
|
||||
return id;
|
||||
});
|
||||
}
|
||||
|
||||
async function updateWithConsistencyCheck(context, campaignId, entity) {
|
||||
await knex.transaction(async tx => {
|
||||
await shares.enforceEntityPermissionTx(tx, context, 'campaign', campaignId, 'manageTriggers');
|
||||
|
||||
const existing = await tx('campaign').where({campaign: campaignId, id: entity.id}).first();
|
||||
if (!existing) {
|
||||
throw new interoperableErrors.NotFoundError();
|
||||
}
|
||||
|
||||
const existingHash = hash(existing);
|
||||
if (existingHash !== entity.originalHash) {
|
||||
throw new interoperableErrors.ChangedError();
|
||||
}
|
||||
|
||||
await _validateAndPreprocess(tx, context, campaignId, entity);
|
||||
|
||||
await tx('triggers').where({campaign: campaignId, id: entity.id}).update(filterObject(entity, allowedKeys));
|
||||
});
|
||||
}
|
||||
|
||||
async function removeTx(tx, context, campaignId, id) {
|
||||
await shares.enforceEntityPermissionTx(tx, context, 'campaign', campaignId, 'manageTriggers');
|
||||
|
||||
await tx('triggers').where({campaign: campaignId, id}).del();
|
||||
|
||||
await knex.schema.dropTableIfExists('trigger__' + id);
|
||||
}
|
||||
|
||||
async function remove(context, campaignId, id) {
|
||||
await knex.transaction(async tx => {
|
||||
await removeTx(tx, context, campaignId, id);
|
||||
});
|
||||
}
|
||||
|
||||
async function removeAllByCampaignIdTx(tx, context, campaignId) {
|
||||
const entities = await tx('triggers').where('list', campaignId).select(['id']);
|
||||
for (const entity of entities) {
|
||||
await removeTx(tx, context, campaignId, entity.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This is to handle circular dependency with campaigns.js
|
||||
Object.assign(module.exports, {
|
||||
hash,
|
||||
getById,
|
||||
listByCampaignDTAjax,
|
||||
listByListDTAjax, create,
|
||||
updateWithConsistencyCheck,
|
||||
removeTx,
|
||||
remove,
|
||||
removeAllByCampaignIdTx
|
||||
});
|
40
routes/rest/triggers.js
Normal file
40
routes/rest/triggers.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
'use strict';
|
||||
|
||||
const passport = require('../../lib/passport');
|
||||
const triggers = require('../../models/triggers');
|
||||
|
||||
const router = require('../../lib/router-async').create();
|
||||
|
||||
|
||||
router.postAsync('/triggers-by-campaign-table/:campaignId', passport.loggedIn, async (req, res) => {
|
||||
return res.json(await triggers.listByCampaignDTAjax(req.context, req.params.campaignId, req.body));
|
||||
});
|
||||
|
||||
router.postAsync('/triggers-by-list-table/:listId', passport.loggedIn, async (req, res) => {
|
||||
return res.json(await triggers.listByListDTAjax(req.context, req.params.listId, req.body));
|
||||
});
|
||||
|
||||
router.getAsync('/triggers/:campaignId/:triggerId', passport.loggedIn, async (req, res) => {
|
||||
const entity = await triggers.getById(req.context, req.params.campaignId, req.params.triggerId);
|
||||
entity.hash = triggers.hash(entity);
|
||||
return res.json(entity);
|
||||
});
|
||||
|
||||
router.postAsync('/triggers/:campaignId', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
return res.json(await triggers.create(req.context, req.params.campaignId, req.body));
|
||||
});
|
||||
|
||||
router.putAsync('/triggers/:campaignId/:triggerId', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
const entity = req.body;
|
||||
entity.id = parseInt(req.params.triggerId);
|
||||
|
||||
await triggers.updateWithConsistencyCheck(req.context, req.params.campaignId, entity);
|
||||
return res.json();
|
||||
});
|
||||
|
||||
router.deleteAsync('/triggers/:campaignId/:triggerId', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
await triggers.remove(req.context, req.params.campaignId, req.params.triggerId);
|
||||
return res.json();
|
||||
});
|
||||
|
||||
module.exports = router;
|
|
@ -6,6 +6,8 @@ const {getGlobalNamespaceId} = require('../../../shared/namespaces');
|
|||
const entityTypesAddNamespace = ['list', 'custom_form', 'template', 'campaign', 'report', 'report_template', 'user'];
|
||||
const shareableEntityTypes = ['list', 'custom_form', 'template', 'campaign', 'report', 'report_template', 'namespace', 'send_configuration', 'mosaico_template'];
|
||||
const { MailerType, getSystemSendConfigurationId } = require('../../../shared/send-configurations');
|
||||
const { enforce } = require('../../../lib/helpers');
|
||||
const { EntityVals: TriggerEntityVals, ActionVals: TriggerActionVals } = require('../../../shared/triggers');
|
||||
|
||||
const entityTypesWithFiles = {
|
||||
campaign: {
|
||||
|
@ -354,7 +356,7 @@ async function migrateCustomFields(knex) {
|
|||
// Upgrade custom fields
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
await knex.schema.table('custom_fields', table => {
|
||||
table.text('settings');
|
||||
table.text('settings', 'longtext');
|
||||
});
|
||||
|
||||
await knex.schema.table('custom_fields', table => {
|
||||
|
@ -410,7 +412,7 @@ async function migrateSegments(knex) {
|
|||
// Upgrade segments
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
await knex.schema.table('segments', table => {
|
||||
table.text('settings');
|
||||
table.text('settings', 'longtext');
|
||||
});
|
||||
|
||||
await knex.schema.table('segments', table => {
|
||||
|
@ -946,6 +948,33 @@ async function migrateAttachments(knex) {
|
|||
await knex.schema.dropTableIfExists('attachments');
|
||||
}
|
||||
|
||||
async function migrateTriggers(knex) {
|
||||
await knex.schema.table('triggers', table => {
|
||||
table.renameColumn('rule', 'entity');
|
||||
table.renameColumn('column', 'action');
|
||||
table.renameColumn('dest_campaign', 'campaign');
|
||||
table.renameColumn('seconds', 'seconds_after');
|
||||
});
|
||||
|
||||
const triggers = await knex('triggers');
|
||||
|
||||
for (const trigger of triggers) {
|
||||
const campaign = await knex('campaigns').where('id', trigger.campaign).first();
|
||||
|
||||
enforce(campaign.list === trigger.list, 'The list of trigger and campaign have to be the same.');
|
||||
|
||||
enforce(trigger.entity in TriggerEntityVals);
|
||||
enforce(trigger.action in TriggerActionVals[trigger.entity]);
|
||||
}
|
||||
|
||||
await knex.schema.table('triggers', table => {
|
||||
table.dropForeign('list', 'triggers_ibfk_1');
|
||||
table.dropColumn('list');
|
||||
});
|
||||
|
||||
await knex.schema.dropTableIfExists('trigger');
|
||||
}
|
||||
|
||||
exports.up = (knex, Promise) => (async() => {
|
||||
await migrateBase(knex);
|
||||
await addNamespaces(knex);
|
||||
|
@ -966,6 +995,8 @@ exports.up = (knex, Promise) => (async() => {
|
|||
await addFiles(knex);
|
||||
|
||||
await migrateAttachments(knex);
|
||||
|
||||
await migrateTriggers(knex);
|
||||
})();
|
||||
|
||||
exports.down = (knex, Promise) => (async() => {
|
||||
|
|
|
@ -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…
Reference in a new issue