Added links to preview delivered messages
This commit is contained in:
parent
cf0042c50a
commit
b6555ffd04
3 changed files with 133 additions and 96 deletions
|
@ -53,27 +53,7 @@ router.get('/:campaign/:list/:subscription', (req, res, next) => {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
campaigns.getMail(campaign.id, list.id, subscription.id, (err, mail) => {
|
let renderHtml = (html, renderTags) => {
|
||||||
if (err) {
|
|
||||||
req.flash('danger', err.message || err);
|
|
||||||
return res.redirect('/');
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
if (!mail && !req.user) {
|
|
||||||
err = new Error('Not Found');
|
|
||||||
err.status = 404;
|
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
let renderAndShow = (html, renderTags) => {
|
|
||||||
|
|
||||||
// rewrite links to count clicks
|
|
||||||
links.updateLinks(campaign, list, subscription, serviceUrl, html, (err, html) => {
|
|
||||||
if (err) {
|
|
||||||
req.flash('danger', err.message || err);
|
|
||||||
return res.redirect('/');
|
|
||||||
}
|
|
||||||
|
|
||||||
res.render('archive/view', {
|
res.render('archive/view', {
|
||||||
layout: 'archive/layout',
|
layout: 'archive/layout',
|
||||||
message: renderTags ? tools.formatMessage(serviceUrl, campaign, list, subscription, html) : html,
|
message: renderTags ? tools.formatMessage(serviceUrl, campaign, list, subscription, html) : html,
|
||||||
|
@ -81,6 +61,19 @@ router.get('/:campaign/:list/:subscription', (req, res, next) => {
|
||||||
list,
|
list,
|
||||||
subscription
|
subscription
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
let renderAndShow = (html, renderTags) => {
|
||||||
|
if (req.query.track === 'no') {
|
||||||
|
return renderHtml(html, renderTags);
|
||||||
|
}
|
||||||
|
// rewrite links to count clicks
|
||||||
|
links.updateLinks(campaign, list, subscription, serviceUrl, html, (err, html) => {
|
||||||
|
if (err) {
|
||||||
|
req.flash('danger', err.message || err);
|
||||||
|
return res.redirect('/');
|
||||||
|
}
|
||||||
|
renderHtml(html, renderTags);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -108,7 +101,6 @@ router.get('/:campaign/:list/:subscription', (req, res, next) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
|
@ -407,7 +407,7 @@ router.post('/preview/:id', passport.parseForm, passport.csrfProtection, (req, r
|
||||||
return res.redirect('/lists/subscription/' + encodeURIComponent(listId) + '/add/?is-test=true');
|
return res.redirect('/lists/subscription/' + encodeURIComponent(listId) + '/add/?is-test=true');
|
||||||
}
|
}
|
||||||
|
|
||||||
res.redirect('/archive/' + encodeURIComponent(campaign) + '/' + encodeURIComponent(list) + '/' + encodeURIComponent(subscription));
|
res.redirect('/archive/' + encodeURIComponent(campaign) + '/' + encodeURIComponent(list) + '/' + encodeURIComponent(subscription) + '?track=no');
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/opened/:id', passport.csrfProtection, (req, res) => {
|
router.get('/opened/:id', passport.csrfProtection, (req, res) => {
|
||||||
|
@ -564,6 +564,16 @@ router.post('/clicked/ajax/:id/:linkId', (req, res) => {
|
||||||
data: []
|
data: []
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
lists.get(campaign.list, (err, list) => {
|
||||||
|
if (err) {
|
||||||
|
return res.json({
|
||||||
|
error: err && err.message || err,
|
||||||
|
data: []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let campaignCid = campaign.cid;
|
||||||
|
let listCid = list.cid;
|
||||||
|
|
||||||
let columns = ['#', 'email', 'first_name', 'last_name', 'campaign_tracker__' + campaign.id + '`.`created', 'count'];
|
let columns = ['#', 'email', 'first_name', 'last_name', 'campaign_tracker__' + campaign.id + '`.`created', 'count'];
|
||||||
campaigns.filterClickedSubscribers(campaign, linkId, req.body, columns, (err, data, total, filteredTotal) => {
|
campaigns.filterClickedSubscribers(campaign, linkId, req.body, columns, (err, data, total, filteredTotal) => {
|
||||||
|
@ -579,7 +589,7 @@ router.post('/clicked/ajax/:id/:linkId', (req, res) => {
|
||||||
recordsTotal: total,
|
recordsTotal: total,
|
||||||
recordsFiltered: filteredTotal,
|
recordsFiltered: filteredTotal,
|
||||||
data: data.map((row, i) => [
|
data: data.map((row, i) => [
|
||||||
(Number(req.body.start) || 0) + 1 + i,
|
'<a href="/archive/' + encodeURIComponent(campaignCid) + '/' + encodeURIComponent(listCid) + '/' + encodeURIComponent(row.cid) + '?track=no">' + ((Number(req.body.start) || 0) + 1 + i) + '</a>',
|
||||||
htmlescape(row.email || ''),
|
htmlescape(row.email || ''),
|
||||||
htmlescape(row.firstName || ''),
|
htmlescape(row.firstName || ''),
|
||||||
htmlescape(row.lastName || ''),
|
htmlescape(row.lastName || ''),
|
||||||
|
@ -590,6 +600,7 @@ router.post('/clicked/ajax/:id/:linkId', (req, res) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/status/ajax/:id/:status', (req, res) => {
|
router.post('/status/ajax/:id/:status', (req, res) => {
|
||||||
|
@ -603,6 +614,17 @@ router.post('/status/ajax/:id/:status', (req, res) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lists.get(campaign.list, (err, list) => {
|
||||||
|
if (err) {
|
||||||
|
return res.json({
|
||||||
|
error: err && err.message || err,
|
||||||
|
data: []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let campaignCid = campaign.cid;
|
||||||
|
let listCid = list.cid;
|
||||||
|
|
||||||
let columns = ['#', 'email', 'first_name', 'last_name', 'campaign__' + campaign.id + '`.`updated'];
|
let columns = ['#', 'email', 'first_name', 'last_name', 'campaign__' + campaign.id + '`.`updated'];
|
||||||
campaigns.filterStatusSubscribers(campaign, status, req.body, columns, (err, data, total, filteredTotal) => {
|
campaigns.filterStatusSubscribers(campaign, status, req.body, columns, (err, data, total, filteredTotal) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -617,7 +639,7 @@ router.post('/status/ajax/:id/:status', (req, res) => {
|
||||||
recordsTotal: total,
|
recordsTotal: total,
|
||||||
recordsFiltered: filteredTotal,
|
recordsFiltered: filteredTotal,
|
||||||
data: data.map((row, i) => [
|
data: data.map((row, i) => [
|
||||||
(Number(req.body.start) || 0) + 1 + i,
|
'<a href="/archive/' + encodeURIComponent(campaignCid) + '/' + encodeURIComponent(listCid) + '/' + encodeURIComponent(row.cid) + '?track=no">' + ((Number(req.body.start) || 0) + 1 + i) + '</a>',
|
||||||
htmlescape(row.email || ''),
|
htmlescape(row.email || ''),
|
||||||
htmlescape(row.firstName || ''),
|
htmlescape(row.firstName || ''),
|
||||||
htmlescape(row.lastName || ''),
|
htmlescape(row.lastName || ''),
|
||||||
|
@ -628,6 +650,7 @@ router.post('/status/ajax/:id/:status', (req, res) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/delete', passport.parseForm, passport.csrfProtection, (req, res) => {
|
router.post('/delete', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||||
|
|
|
@ -264,12 +264,30 @@ router.post('/status/ajax/:id', (req, res) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
campaigns.get(trigger.destCampaign, false, (err, campaign) => {
|
||||||
|
if (err) {
|
||||||
|
return res.json({
|
||||||
|
error: err && err.message || err,
|
||||||
|
data: []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
lists.get(trigger.list, (err, list) => {
|
||||||
|
if (err) {
|
||||||
|
return res.json({
|
||||||
|
error: err && err.message || err,
|
||||||
|
data: []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let campaignCid = campaign && campaign.cid;
|
||||||
|
let listCid = list && list.cid;
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
draw: req.body.draw,
|
draw: req.body.draw,
|
||||||
recordsTotal: total,
|
recordsTotal: total,
|
||||||
recordsFiltered: filteredTotal,
|
recordsFiltered: filteredTotal,
|
||||||
data: data.map((row, i) => [
|
data: data.map((row, i) => [
|
||||||
(Number(req.body.start) || 0) + 1 + i,
|
'<a href="/archive/' + encodeURIComponent(campaignCid) + '/' + encodeURIComponent(listCid) + '/' + encodeURIComponent(row.cid) + '?track=no">' + ((Number(req.body.start) || 0) + 1 + i) + '</a>',
|
||||||
htmlescape(row.email || ''),
|
htmlescape(row.email || ''),
|
||||||
htmlescape(row.firstName || ''),
|
htmlescape(row.firstName || ''),
|
||||||
htmlescape(row.lastName || ''),
|
htmlescape(row.lastName || ''),
|
||||||
|
@ -279,6 +297,10 @@ router.post('/status/ajax/:id', (req, res) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue