Merge branch 'pr453'
This commit is contained in:
commit
ee0d148427
11 changed files with 53 additions and 17 deletions
|
@ -16,7 +16,7 @@ let _ = require('../translate')._;
|
|||
let util = require('util');
|
||||
let tableHelpers = require('../table-helpers');
|
||||
|
||||
let allowedKeys = ['description', 'from', 'address', 'reply_to', 'subject', 'editor_name', 'editor_data', 'template', 'source_url', 'list', 'segment', 'html', 'text', 'click_tracking_disabled', 'open_tracking_disabled'];
|
||||
let allowedKeys = ['description', 'from', 'address', 'reply_to', 'subject', 'editor_name', 'editor_data', 'template', 'source_url', 'list', 'segment', 'html', 'text', 'click_tracking_disabled', 'open_tracking_disabled', 'unsubscribe'];
|
||||
|
||||
module.exports.list = (start, limit, callback) => {
|
||||
tableHelpers.list('campaigns', ['*'], 'scheduled', null, start, limit, callback);
|
||||
|
|
11
lib/tools.js
11
lib/tools.js
|
@ -181,7 +181,7 @@ function validateEmail(address, checkBlocked, callback) {
|
|||
|
||||
function getMessageLinks(serviceUrl, campaign, list, subscription) {
|
||||
return {
|
||||
LINK_UNSUBSCRIBE: urllib.resolve(serviceUrl, '/subscription/' + list.cid + '/unsubscribe/' + subscription.cid + '?c=' + campaign.cid),
|
||||
LINK_UNSUBSCRIBE: campaign.unsubscribe ? campaign.unsubscribe : urllib.resolve(serviceUrl, '/subscription/' + list.cid + '/unsubscribe/' + subscription.cid + '?c=' + campaign.cid),
|
||||
LINK_PREFERENCES: urllib.resolve(serviceUrl, '/subscription/' + list.cid + '/manage/' + subscription.cid),
|
||||
LINK_BROWSER: urllib.resolve(serviceUrl, '/archive/' + campaign.cid + '/' + list.cid + '/' + subscription.cid),
|
||||
CAMPAIGN_ID: campaign.cid,
|
||||
|
@ -195,7 +195,7 @@ function formatMessage(serviceUrl, campaign, list, subscription, message, filter
|
|||
|
||||
let links = getMessageLinks(serviceUrl, campaign, list, subscription);
|
||||
|
||||
let getValue = key => {
|
||||
let getTagValue = key => {
|
||||
key = (key || '').toString().toUpperCase().trim();
|
||||
if (links.hasOwnProperty(key)) {
|
||||
return links[key];
|
||||
|
@ -211,15 +211,18 @@ function formatMessage(serviceUrl, campaign, list, subscription, message, filter
|
|||
return false;
|
||||
};
|
||||
|
||||
return message.replace(/\[([a-z0-9_]+)(?:\/([^\]]+))?\]/ig, (match, identifier, fallback) => {
|
||||
let tagReplace = message =>
|
||||
message.replace(/\[([a-z0-9_]+)(?:\/([^\]]+))?\]/ig, (match, identifier, fallback) => {
|
||||
identifier = identifier.toUpperCase();
|
||||
let value = getValue(identifier);
|
||||
let value = getTagValue(identifier);
|
||||
if (value === false) {
|
||||
return match;
|
||||
}
|
||||
value = (value || fallback || '').trim();
|
||||
return filter(value);
|
||||
});
|
||||
|
||||
return tagReplace(tagReplace(message));
|
||||
}
|
||||
|
||||
function prepareHtml(html, callback) {
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"schemaVersion": 32
|
||||
"schemaVersion": 33
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ router.get('/create', passport.csrfProtection, (req, res) => {
|
|||
data.list = Number(data.list.split(':').shift());
|
||||
}
|
||||
|
||||
settings.list(['defaultFrom', 'defaultAddress', 'defaultSubject'], (err, configItems) => {
|
||||
settings.list(['defaultFrom', 'defaultAddress', 'defaultSubject', 'defaultUnsubscribe'], (err, configItems) => {
|
||||
if (err) {
|
||||
req.flash('danger', err.message || err);
|
||||
return res.redirect('/');
|
||||
|
@ -93,6 +93,7 @@ router.get('/create', passport.csrfProtection, (req, res) => {
|
|||
data.address = data.address || configItems.defaultAddress;
|
||||
data.replyTo = data.replyTo || '';
|
||||
data.subject = data.subject || configItems.defaultSubject;
|
||||
data.unsubscribe = data.unsubscribe || configItems.defaultUnsubscribe;
|
||||
|
||||
let view;
|
||||
switch (req.query.type) {
|
||||
|
|
|
@ -16,7 +16,7 @@ let _ = require('../lib/translate')._;
|
|||
|
||||
let settings = require('../lib/models/settings');
|
||||
|
||||
let allowedKeys = ['service_url', 'smtp_hostname', 'smtp_port', 'smtp_encryption', 'smtp_disable_auth', 'smtp_user', 'smtp_pass', 'admin_email', 'smtp_log', 'smtp_max_connections', 'smtp_max_messages', 'smtp_self_signed', 'default_from', 'default_address', 'default_subject', 'default_homepage', 'default_postaddress', 'default_sender', 'verp_hostname', 'verp_use', 'disable_wysiwyg', 'pgp_private_key', 'pgp_passphrase', 'ua_code', 'shoutout', 'disable_confirmations', 'smtp_throttling', 'dkim_api_key', 'dkim_private_key', 'dkim_selector', 'dkim_domain', 'mail_transport', 'ses_key', 'ses_secret', 'ses_region', 'x_mailer'];
|
||||
let allowedKeys = ['service_url', 'smtp_hostname', 'smtp_port', 'smtp_encryption', 'smtp_disable_auth', 'smtp_user', 'smtp_pass', 'admin_email', 'smtp_log', 'smtp_max_connections', 'smtp_max_messages', 'smtp_self_signed', 'default_from', 'default_address', 'default_subject', 'default_homepage', 'default_postaddress', 'default_sender', 'verp_hostname', 'verp_use', 'disable_wysiwyg', 'pgp_private_key', 'pgp_passphrase', 'ua_code', 'shoutout', 'disable_confirmations', 'smtp_throttling', 'dkim_api_key', 'dkim_private_key', 'dkim_selector', 'dkim_domain', 'mail_transport', 'ses_key', 'ses_secret', 'ses_region', 'x_mailer', 'default_unsubscribe'];
|
||||
|
||||
router.all('/*', (req, res, next) => {
|
||||
if (!req.user) {
|
||||
|
|
|
@ -381,7 +381,7 @@ function formatMessage(message, callback) {
|
|||
|
||||
let listUnsubscribe = null;
|
||||
if (!list.listunsubscribeDisabled) {
|
||||
listUnsubscribe = url.resolve(configItems.serviceUrl, '/subscription/' + list.cid + '/unsubscribe/' + message.subscription.cid);
|
||||
listUnsubscribe = campaign.unsubscribe ? tools.formatMessage(configItems.serviceUrl, campaign, list, message.subscription, campaign.unsubscribe) : url.resolve(configItems.serviceUrl, '/subscription/' + list.cid + '/unsubscribe/' + message.subscription.cid);
|
||||
}
|
||||
|
||||
return callback(null, {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '31';
|
||||
SET @schema_version = '32';
|
||||
|
||||
# Set default X-Mailer header value
|
||||
LOCK TABLES `settings` WRITE;
|
||||
|
|
13
setup/sql/upgrade-00033.sql
Normal file
13
setup/sql/upgrade-00033.sql
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '33';
|
||||
|
||||
# Adds new column 'unsubscribe' to campaign table.
|
||||
ALTER TABLE campaigns ADD COLUMN `unsubscribe` VARCHAR(255) NOT NULL DEFAULT '' AFTER `subject`;
|
||||
|
||||
# Footer section. Updates schema version in settings
|
||||
LOCK TABLES `settings` WRITE;
|
||||
/*!40000 ALTER TABLE `settings` DISABLE KEYS */;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
/*!40000 ALTER TABLE `settings` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
|
@ -106,6 +106,12 @@
|
|||
<input type="text" class="form-control" name="subject" id="subject" value="{{subject}}" placeholder="{{#translate}}Keep it relevant and non-spammy{{/translate}}" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="unsubscribe" class="col-sm-2 control-label">{{#translate}}Custom unsubscribe (URL){{/translate}}</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" name="unsubscribe" id="unsubscribe" value="{{unsubscribe}}" placeholder="{{#translate}}Set a custom unsubscribe url{{/translate}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-offset-2">
|
||||
<div class="checkbox">
|
||||
|
|
|
@ -117,6 +117,12 @@
|
|||
<input type="text" class="form-control" name="subject" id="subject" value="{{subject}}" placeholder="{{#translate}}Keep it relevant and non-spammy{{/translate}}" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="unsubscribe" class="col-sm-2 control-label">{{#translate}}Custom unsubscribe (URL){{/translate}}</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" name="unsubscribe" id="unsubscribe" value="{{unsubscribe}}" placeholder="{{#translate}}Set a custom unsubscribe url{{/translate}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-offset-2">
|
||||
<div class="checkbox">
|
||||
|
|
|
@ -130,6 +130,13 @@
|
|||
<span class="help-block"> </span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="default-unsubscribe" class="col-sm-2 control-label">{{#translate}}Default custom unsubscribe (URL)){{/translate}}</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="url" class="form-control" name="default-unsubscribe" id="default-unsubscribe" value="{{defaultUnsubscribe}}" placeholder="{{#translate}}Custom unsubscribe URL, eg. http://example.com/unsubscribe/[EMAIL]{{/translate}}">
|
||||
<span class="help-block">{{#translate}}Set a custom unsubscribe url.{{/translate}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</fieldset>
|
||||
|
|
Loading…
Reference in a new issue