mailtrain/shared/campaigns.js
Tomas Bures 30b361290b - Refactoring of the mail sending part. Mail queue (table 'queued') is now used also for all test emails.
- More options how to send test emails.
- Fixed problems with pausing a campaign (#593)
- Started rework of transactional sender of templates (#606), however this contains functionality regression at the moment because it does not interpret templates as HBS. It needs HBS option for templates as described in https://github.com/Mailtrain-org/mailtrain/issues/611#issuecomment-502345227

TODO:
- detect sending errors connected to not able to contact the mailer and pause/retry campaing and queued sending - don't mark the recipients as BOUNCED
- add FAILED campaign state and fall into it if sending to campaign consistently fails (i.e. the error with sending is not temporary)
- if the same happends for queued email, delete the message
2019-06-25 07:18:06 +02:00

79 lines
No EOL
1.5 KiB
JavaScript

'use strict';
const CampaignSource = {
MIN: 1,
TEMPLATE: 1,
CUSTOM: 2,
CUSTOM_FROM_TEMPLATE: 3,
CUSTOM_FROM_CAMPAIGN: 4,
URL: 5,
MAX: 5
};
const CampaignType = {
MIN: 1,
REGULAR: 1,
RSS: 2,
RSS_ENTRY: 3,
TRIGGERED: 4,
MAX: 4
};
const CampaignStatus = {
MIN: 1,
// For campaign types: NORMAL, RSS_ENTRY
IDLE: 1,
SCHEDULED: 2,
FINISHED: 3,
PAUSED: 4,
// For campaign types: RSS, TRIGGERED
INACTIVE: 5,
ACTIVE: 6,
// For campaign types: NORMAL, RSS_ENTRY
SENDING: 7,
PAUSING: 8,
MAX: 9
};
const campaignOverridables = ['from_name', 'from_email', 'reply_to'];
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 = 'sendWithoutOverrides';
if (allowedOverride) {
requiredPermission = 'sendWithAllowedOverrides';
}
if (disallowedOverride) {
requiredPermission = 'sendWithAnyOverrides';
}
return requiredPermission;
}
module.exports = {
CampaignSource,
CampaignType,
CampaignStatus,
campaignOverridables,
getSendConfigurationPermissionRequiredForSend
};