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:
parent
ef605c5191
commit
804fcffa6c
1 changed files with 18 additions and 2 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue