Implementation of archive route. Simplified from v1. Not tested.

This commit is contained in:
Tomas Bures 2018-09-22 18:12:22 +02:00
parent a9e1700dbe
commit dda95ecdb3
9 changed files with 320 additions and 272 deletions

31
routes/archive.js Normal file
View file

@ -0,0 +1,31 @@
'use strict';
const router = require('../lib/router-async').create();
const CampaignSender = require('../lib/campaign-sender');
router.get('/:campaign/:list/:subscription', (req, res, next) => {
const cs = new CampaignSender();
cs.init({campaignCid: req.params.campaign})
.then(() => cs.getMessage(req.params.list, req.params.subscription))
.then(result => {
const {html} = result;
res.render('partials/tracking-scripts', {
layout: 'archive/layout-raw'
}, (err, scripts) => {
if (err) {
return next(err);
}
html = scripts ? html.replace(/<\/body\b/i, match => scripts + match) : html;
res.render('archive/view-raw', {
layout: 'archive/layout-raw',
message: html
});
});
})
.catch(err => next(err));
});
module.exports = router;