0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00

Subscribers: store post id using the postlookup fn

This commit is contained in:
kirrg001 2016-05-07 10:33:04 +02:00 committed by Hannah Wolfe
parent ef605c5191
commit 804fcffa6c

View file

@ -4,7 +4,9 @@ var path = require('path'),
// Dirty requires
api = require('../../../api'),
errors = require('../../../errors'),
templates = require('../../../controllers/frontend/templates'),
postlookup = require('../../../controllers/frontend/post-lookup'),
setResponseContext = require('../../../controllers/frontend/context');
function controller(req, res) {
@ -46,8 +48,22 @@ function handleSource(req, res, next) {
req.body.subscribed_referrer = req.body.referrer;
delete req.body.location;
delete req.body.referrer;
// do something here to get post_id
next();
postlookup(req.body.subscribed_url)
.then(function (result) {
if (result && result.post) {
req.body.post_id = result.post.id;
}
next();
})
.catch(function (err) {
if (err instanceof errors.NotFoundError) {
return next();
}
next(err);
});
}
function storeSubscriber(req, res, next) {