Show 404 error for unresolved tracking urls

This commit is contained in:
Andris Reinman 2016-06-08 11:16:32 +03:00
parent 6eed682d93
commit e2ae925b97
2 changed files with 13 additions and 1 deletions

View file

@ -18,7 +18,7 @@ module.exports.resolve = (campaignCid, linkCid, callback) => {
return callback(err);
}
if (!campaign) {
return callback('Campaign not found');
return callback(null, false);
}
db.getConnection((err, connection) => {
if (err) {

View file

@ -36,6 +36,18 @@ router.get('/:campaign/:list/:subscription/:link', (req, res, next) => {
req.flash('danger', err.message || err);
return res.redirect('/');
}
if (!linkId || !url) {
log.error('Redirect', 'Unresolved URL: <%s>', req.url);
res.status(404);
return res.render('archive/view', {
layout: 'archive/layout',
message: 'Oops, we couldn\'t find a link for the URL you clicked',
campaign: {
subject: 'Error 404'
}
});
}
links.countClick(req.ip, req.params.campaign, req.params.list, req.params.subscription, linkId, (err, status) => {
if (err) {
log.error('Redirect', err.stack || err);