Implementation of archive route. Simplified from v1. Not tested.
This commit is contained in:
parent
a9e1700dbe
commit
dda95ecdb3
9 changed files with 320 additions and 272 deletions
31
routes/archive.js
Normal file
31
routes/archive.js
Normal 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;
|
Loading…
Add table
Add a link
Reference in a new issue