Apply last changes in development branch

This commit is contained in:
joker-x 2020-09-06 03:26:57 +02:00
commit 01d9e8b90a
14 changed files with 30 additions and 39 deletions

View file

@ -12162,15 +12162,6 @@
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
"integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ="
},
"premailer-api": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/premailer-api/-/premailer-api-1.0.4.tgz",
"integrity": "sha1-hz9A/DiN3IgG81uY3NKymTeKh08=",
"requires": {
"request": "^2.72.0",
"underscore": "^1.8.3"
}
},
"process-nextick-args": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
@ -13432,11 +13423,6 @@
"resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz",
"integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo="
},
"underscore": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz",
"integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg=="
},
"underscore.string": {
"version": "3.3.5",
"resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3.5.tgz",

View file

@ -102,7 +102,6 @@
"openpgp": "^4.7.2",
"passport": "^0.4.1",
"passport-local": "^1.0.0",
"premailer-api": "^1.0.4",
"request": "^2.88.0",
"request-promise": "^4.2.5",
"serve-favicon": "^2.5.0",

View file

@ -18,6 +18,8 @@ const slugify = require('slugify');
const passport = require('../lib/passport');
const templates = require('../models/templates');
const campaigns = require('../models/campaigns');
const urls = require('../lib/urls')
const { getMergeTagsForBases } = require('../../shared/templates')
const {castToInteger} = require('../lib/helpers');
const {getSystemSendConfigurationId} = require('../../shared/send-configurations');
@ -362,7 +364,9 @@ router.postAsync('/templates/:templateId/send', async (req, res) => {
}
const emails = input.EMAIL.split(',');
const mergeTags = input.TAGS || {};
const mergeTagsGlobal = getMergeTagsForBases(urls.getTrustedUrl(), urls.getSandboxUrl(), urls.getPublicUrl());
const mergeTagsLocal = input.TAGS || {};
const mergeTags = { ...mergeTagsGlobal, ...mergeTagsLocal}
const subject = input.SUBJECT || '';
const attachments = input.ATTACHMENTS || [];

View file

@ -3,23 +3,14 @@
const passport = require('../../lib/passport');
const bluebird = require('bluebird');
const premailerApi = require('premailer-api');
const premailerPrepareAsync = bluebird.promisify(premailerApi.prepare.bind(premailerApi));
const htmlToText = require('html-to-text');
const router = require('../../lib/router-async').create();
router.postAsync('/html-to-text', passport.loggedIn, passport.csrfProtection, async (req, res) => {
if (!req.body.html) {
return res.json({text: ''}); // Premailer crashes very hard when html is empty
}
const email = await premailerPrepareAsync({
html: req.body.html,
fetchHTML: false
});
res.json({text: email.text.replace(/%5B/g, '[').replace(/%5D/g, ']')});
const email = htmlToText.fromString(req.body.html, {wordwrap: 130});
res.json({text: email});
});
module.exports = router;

View file

@ -281,6 +281,11 @@ router.postAsync('/:cid/subscribe', passport.parseForm, corsOrCsrfProtection, as
if (existingSubscription && existingSubscription.status === SubscriptionStatus.SUBSCRIBED) {
await mailHelpers.sendAlreadySubscribed(req.locale, list, email, existingSubscription);
if (req.xhr) {
return res.status(200).json({
msg: tUI('pleaseConfirmSubscription', req.locale)
});
}
res.redirect('/subscription/' + encodeURIComponent(req.params.cid) + '/confirm-subscription-notice');
} else {
@ -325,17 +330,18 @@ router.getAsync('/:cid/widget', cors(corsOptions), async (req, res) => {
title: list.name,
cid: list.cid,
publicKeyUrl: getTrustedUrl('subscription/publickey'),
subscribeUrl: getTrustedUrl(`subscription/${list.cid}/subscribe`),
subscribeUrl: getPublicUrl(`subscription/${list.cid}/subscribe`),
hasPubkey: !!configItems.pgpPrivateKey,
customFields: await fields.forHbs(contextHelpers.getAdminContext(), list.id),
template: {},
template: 'subscription/widget-subscribe.hbs',
layout: null,
};
await injectCustomFormData(req.query.fid || list.default_form, 'web_subscribe', data);
const renderAsync = bluebird.promisify(res.render.bind(res));
const html = await renderAsync('subscription/widget-subscribe', data);
const htmlRenderer = await tools.getTemplate(data.template, req.locale);
const html = htmlRenderer(data);
const response = {
data: {