Added CSV export of subscribers
Fixed some bugs in subscriptions Updated some packages to avoid warnings about vulnerabilities Completed RSS feed campaigns
This commit is contained in:
parent
8683f8c91e
commit
bf69e633c4
47 changed files with 5255 additions and 9651 deletions
|
@ -11,7 +11,7 @@ const lists = require('../models/lists');
|
|||
const fields = require('../models/fields');
|
||||
const sendConfigurations = require('../models/send-configurations');
|
||||
const links = require('../models/links');
|
||||
const {CampaignSource} = require('../shared/campaigns');
|
||||
const {CampaignSource, CampaignType} = require('../shared/campaigns');
|
||||
const {SubscriptionStatus} = require('../shared/lists');
|
||||
const tools = require('../lib/tools');
|
||||
const request = require('request-promise');
|
||||
|
@ -68,7 +68,7 @@ class CampaignSender {
|
|||
return prefix + 'cid:' + cid;
|
||||
});
|
||||
|
||||
html = tools.formatMessage(campaign, list, subscriptionGrouped, mergeTags, html, false, true);
|
||||
html = tools.formatMessage(campaign, list, subscriptionGrouped, mergeTags, html, true);
|
||||
|
||||
text = (text || '').trim()
|
||||
? tools.formatMessage(campaign, list, subscriptionGrouped, mergeTags, text)
|
||||
|
@ -91,7 +91,7 @@ class CampaignSender {
|
|||
replyTo: getOverridable('reply_to'),
|
||||
xMailer: sendConfiguration.x_mailer ? sendConfiguration.x_mailer : false,
|
||||
to: {
|
||||
name: tools.formatMessage(campaign, list, subscriptionGrouped, mergeTags, list.to_name, false, false),
|
||||
name: tools.formatMessage(campaign, list, subscriptionGrouped, mergeTags, list.to_name, false),
|
||||
address: subscriptionGrouped.email
|
||||
},
|
||||
sender: this.useVerpSenderHeader ? campaignAddress + '@' + sendConfiguration.verp_hostname : false,
|
||||
|
@ -125,7 +125,7 @@ class CampaignSender {
|
|||
list: {
|
||||
unsubscribe: null
|
||||
},
|
||||
subject: tools.formatMessage(campaign, list, subscriptionGrouped, mergeTags, getOverridable('subject'), false, false),
|
||||
subject: tools.formatMessage(campaign, list, subscriptionGrouped, mergeTags, getOverridable('subject'), false),
|
||||
html,
|
||||
text,
|
||||
|
||||
|
@ -240,7 +240,7 @@ class CampaignSender {
|
|||
});
|
||||
}
|
||||
|
||||
html = renderTags ? tools.formatMessage(campaign, list, subscriptionGrouped, mergeTags, html, false, true) : html;
|
||||
html = renderTags ? tools.formatMessage(campaign, list, subscriptionGrouped, mergeTags, html, true) : html;
|
||||
|
||||
text = (text || '').trim()
|
||||
? (renderTags ? tools.formatMessage(campaign, list, subscriptionGrouped, mergeTags, text) : text)
|
||||
|
@ -253,12 +253,28 @@ class CampaignSender {
|
|||
};
|
||||
}
|
||||
|
||||
_getExtraTags(campaign) {
|
||||
const tags = {};
|
||||
|
||||
if (campaign.type === CampaignType.RSS_ENTRY) {
|
||||
const rssEntry = campaign.data.rssEntry;
|
||||
tags['RSS_ENTRY_TITLE'] = rssEntry.title;
|
||||
tags['RSS_ENTRY_DATE'] = rssEntry.date;
|
||||
tags['RSS_ENTRY_LINK'] = rssEntry.link;
|
||||
tags['RSS_ENTRY_CONTENT'] = rssEntry.content;
|
||||
tags['RSS_ENTRY_SUMMARY'] = rssEntry.summary;
|
||||
tags['RSS_ENTRY_IMAGE_URL'] = rssEntry.image_url;
|
||||
}
|
||||
|
||||
return tags;
|
||||
}
|
||||
|
||||
async getMessage(listCid, subscriptionCid) {
|
||||
const list = this.listsByCid.get(listCid);
|
||||
const subscriptionGrouped = await subscriptions.getByCid(contextHelpers.getAdminContext(), list.id, subscriptionCid);
|
||||
const flds = this.listsFieldsGrouped.get(list.id);
|
||||
const campaign = this.campaign;
|
||||
const mergeTags = fields.getMergeTags(flds, subscriptionGrouped);
|
||||
const mergeTags = fields.getMergeTags(flds, subscriptionGrouped, this._getExtraTags(campaign));
|
||||
|
||||
return await this._getMessage(campaign, list, subscriptionGrouped, mergeTags, false);
|
||||
}
|
||||
|
@ -272,7 +288,8 @@ class CampaignSender {
|
|||
const subscriptionGrouped = await subscriptions.getByEmail(contextHelpers.getAdminContext(), list.id, email);
|
||||
const flds = this.listsFieldsGrouped.get(listId);
|
||||
const campaign = this.campaign;
|
||||
const mergeTags = fields.getMergeTags(flds, subscriptionGrouped);
|
||||
|
||||
const mergeTags = fields.getMergeTags(flds, subscriptionGrouped, this._getExtraTags(campaign));
|
||||
|
||||
const encryptionKeys = [];
|
||||
for (const fld of flds) {
|
||||
|
@ -314,7 +331,7 @@ class CampaignSender {
|
|||
replyTo: getOverridable('reply_to'),
|
||||
xMailer: sendConfiguration.x_mailer ? sendConfiguration.x_mailer : false,
|
||||
to: {
|
||||
name: tools.formatMessage(campaign, list, subscriptionGrouped, mergeTags, list.to_name, false, false),
|
||||
name: tools.formatMessage(campaign, list, subscriptionGrouped, mergeTags, list.to_name, false),
|
||||
address: subscriptionGrouped.email
|
||||
},
|
||||
sender: this.useVerpSenderHeader ? campaignAddress + '@' + sendConfiguration.verp_hostname : false,
|
||||
|
@ -348,7 +365,7 @@ class CampaignSender {
|
|||
list: {
|
||||
unsubscribe: listUnsubscribe
|
||||
},
|
||||
subject: tools.formatMessage(campaign, list, subscriptionGrouped, mergeTags, getOverridable('subject'), false, false),
|
||||
subject: tools.formatMessage(campaign, list, subscriptionGrouped, mergeTags, getOverridable('subject'), false),
|
||||
html,
|
||||
text,
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ const fs = require('fs');
|
|||
const pathlib = require('path');
|
||||
const Handlebars = require('handlebars');
|
||||
|
||||
const highestLegacySchemaVersion = 29;
|
||||
const highestLegacySchemaVersion = 33;
|
||||
|
||||
const mysqlConfig = {
|
||||
multipleStatements: true
|
||||
|
@ -69,12 +69,12 @@ function getSchemaVersion(callback) {
|
|||
}
|
||||
|
||||
connection.query('SHOW TABLES LIKE "knex_migrations"', (err, rows) => {
|
||||
if (rows) {
|
||||
connection.release();
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
if (rows.length > 0) {
|
||||
connection.release();
|
||||
|
||||
callback(null, highestLegacySchemaVersion);
|
||||
} else {
|
||||
|
|
|
@ -29,6 +29,10 @@ const entityTypes = {
|
|||
entitiesTable: 'campaigns',
|
||||
sharesTable: 'shares_campaign',
|
||||
permissionsTable: 'permissions_campaign',
|
||||
dependentPermissions: {
|
||||
extraColumns: ['parent'],
|
||||
getParent: entity => entity.parent
|
||||
},
|
||||
files: {
|
||||
file: {
|
||||
table: 'files_campaign_file',
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
const fork = require('child_process').fork;
|
||||
const log = require('./log');
|
||||
const path = require('path');
|
||||
const senders = require('./senders');
|
||||
|
||||
let feedcheckProcess;
|
||||
|
||||
|
@ -23,6 +24,8 @@ function spawn(callback) {
|
|||
if (msg.type === 'feedcheck-started') {
|
||||
log.info('Feed', 'Feedcheck process started');
|
||||
return callback();
|
||||
} else if (msg.type === 'entries-added') {
|
||||
senders.scheduleCheck();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -88,7 +88,7 @@ async function tryStartWorkers() {
|
|||
startWorker(report);
|
||||
|
||||
} else {
|
||||
log.info('ReportProcessor', 'No more report to start a worker for');
|
||||
log.info('ReportProcessor', 'No more reports to start a worker for');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
10
lib/tools.js
10
lib/tools.js
|
@ -108,9 +108,7 @@ function validateEmailGetMessage(result, address) {
|
|||
}
|
||||
}
|
||||
|
||||
function formatMessage(campaign, list, subscription, mergeTags, message, filter, isHTML) {
|
||||
filter = typeof filter === 'function' ? filter : (str => str);
|
||||
|
||||
function formatMessage(campaign, list, subscription, mergeTags, message, isHTML) {
|
||||
const links = getMessageLinks(campaign, list, subscription);
|
||||
|
||||
const getValue = key => {
|
||||
|
@ -135,11 +133,11 @@ function formatMessage(campaign, list, subscription, mergeTags, message, filter,
|
|||
return match;
|
||||
}
|
||||
value = (value || fallback || '').trim();
|
||||
return filter(value);
|
||||
return value;
|
||||
});
|
||||
}
|
||||
|
||||
async function prepareHtml(html) {
|
||||
async function prepareHtml(html) {
|
||||
if (!(html || '').toString().trim()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -150,7 +148,7 @@ async function prepareHtml(html) {
|
|||
FetchExternalResources: false, // disables resource loading over HTTP / filesystem
|
||||
ProcessExternalResources: false // do not execute JS within script blocks
|
||||
}
|
||||
});pre
|
||||
});
|
||||
|
||||
const head = win.document.querySelector('head');
|
||||
let hasCharsetTag = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue