Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
// # Posts API
|
2014-06-03 14:05:25 +01:00
|
|
|
// RESTful API for the Post resource
|
2014-08-17 06:17:23 +00:00
|
|
|
var Promise = require('bluebird'),
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
_ = require('lodash'),
|
|
|
|
dataProvider = require('../models'),
|
|
|
|
canThis = require('../permissions').canThis,
|
|
|
|
errors = require('../errors'),
|
|
|
|
utils = require('./utils'),
|
2015-06-22 21:11:35 +01:00
|
|
|
pipeline = require('../utils/pipeline'),
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
|
|
|
|
docName = 'posts',
|
2015-01-07 17:25:32 +00:00
|
|
|
allowedIncludes = ['created_by', 'updated_by', 'published_by', 'author', 'tags', 'fields', 'next', 'previous'],
|
2014-05-09 12:11:29 +02:00
|
|
|
posts;
|
2013-12-06 09:51:35 +01:00
|
|
|
|
2014-06-03 14:05:25 +01:00
|
|
|
/**
|
2015-06-22 21:11:35 +01:00
|
|
|
* ### Posts API Methods
|
2014-06-03 14:05:25 +01:00
|
|
|
*
|
|
|
|
* **See:** [API Methods](index.js.html#api%20methods)
|
|
|
|
*/
|
2013-12-06 09:51:35 +01:00
|
|
|
posts = {
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
/**
|
2015-06-22 21:11:35 +01:00
|
|
|
* ## Browse
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
* Find a paginated set of posts
|
2014-06-03 14:05:25 +01:00
|
|
|
*
|
|
|
|
* Will only return published posts unless we have an authenticated user and an alternative status
|
|
|
|
* parameter.
|
|
|
|
*
|
|
|
|
* Will return without static pages unless told otherwise
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @public
|
2015-05-05 18:06:43 -05:00
|
|
|
* @param {{context, page, limit, status, staticPages, tag, featured}} options (optional)
|
2015-06-22 21:11:35 +01:00
|
|
|
* @returns {Promise<Posts>} Posts Collection with Meta
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
*/
|
2013-12-06 09:51:35 +01:00
|
|
|
browse: function browse(options) {
|
2015-06-22 21:11:35 +01:00
|
|
|
var tasks;
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
|
2015-06-22 21:11:35 +01:00
|
|
|
/**
|
|
|
|
* ### Handle Permissions
|
|
|
|
* We need to either be an authorised user, or only return published posts.
|
|
|
|
* @param {Object} options
|
|
|
|
* @returns {Object} options
|
|
|
|
*/
|
|
|
|
function handlePermissions(options) {
|
|
|
|
if (!(options.context && options.context.user)) {
|
|
|
|
options.status = 'published';
|
|
|
|
}
|
|
|
|
|
|
|
|
return options;
|
2014-04-08 15:40:33 +02:00
|
|
|
}
|
2014-04-27 18:58:34 +02:00
|
|
|
|
2015-06-22 21:11:35 +01:00
|
|
|
/**
|
|
|
|
* ### Model Query
|
|
|
|
* Make the call to the Model layer
|
|
|
|
* @param {Object} options
|
|
|
|
* @returns {Object} options
|
|
|
|
*/
|
|
|
|
function modelQuery(options) {
|
|
|
|
return dataProvider.Post.findPage(options);
|
2014-04-27 18:58:34 +02:00
|
|
|
}
|
|
|
|
|
2015-06-22 21:11:35 +01:00
|
|
|
// Push all of our tasks into a `tasks` array in the correct order
|
|
|
|
tasks = [utils.validate(docName), handlePermissions, utils.convertOptions(allowedIncludes), modelQuery];
|
|
|
|
|
|
|
|
// Pipeline calls each task passing the result of one to be the arguments for the next
|
|
|
|
return pipeline(tasks, options);
|
2013-12-06 09:51:35 +01:00
|
|
|
},
|
|
|
|
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
/**
|
2015-06-22 21:11:35 +01:00
|
|
|
* ## Read
|
2015-04-16 13:40:32 -06:00
|
|
|
* Find a post, by ID, UUID, or Slug
|
2014-06-03 14:05:25 +01:00
|
|
|
*
|
|
|
|
* @public
|
2015-06-22 21:11:35 +01:00
|
|
|
* @param {Object} options
|
|
|
|
* @return {Promise<Post>} Post
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
*/
|
2014-04-08 15:40:33 +02:00
|
|
|
read: function read(options) {
|
2015-04-16 13:40:32 -06:00
|
|
|
var attrs = ['id', 'slug', 'status', 'uuid'],
|
2015-06-22 21:11:35 +01:00
|
|
|
tasks;
|
2014-04-19 17:03:20 +02:00
|
|
|
|
2015-06-22 21:11:35 +01:00
|
|
|
/**
|
|
|
|
* ### Handle Permissions
|
|
|
|
* We need to either be an authorised user, or only return published posts.
|
|
|
|
* @param {Object} options
|
|
|
|
* @returns {Object} options
|
|
|
|
*/
|
|
|
|
function handlePermissions(options) {
|
|
|
|
if (!options.data.uuid && !(options.context && options.context.user)) {
|
|
|
|
options.data.status = 'published';
|
|
|
|
}
|
|
|
|
return options;
|
2014-04-08 15:40:33 +02:00
|
|
|
}
|
|
|
|
|
2015-06-22 21:11:35 +01:00
|
|
|
/**
|
|
|
|
* ### Model Query
|
|
|
|
* Make the call to the Model layer
|
|
|
|
* @param {Object} options
|
|
|
|
* @returns {Object} options
|
|
|
|
*/
|
|
|
|
function modelQuery(options) {
|
|
|
|
return dataProvider.Post.findOne(options.data, _.omit(options, ['data']));
|
2014-04-27 18:58:34 +02:00
|
|
|
}
|
|
|
|
|
2015-06-22 21:11:35 +01:00
|
|
|
// Push all of our tasks into a `tasks` array in the correct order
|
|
|
|
tasks = [utils.validate(docName, attrs), handlePermissions, utils.convertOptions(allowedIncludes), modelQuery];
|
|
|
|
|
|
|
|
// Pipeline calls each task passing the result of one to be the arguments for the next
|
|
|
|
return pipeline(tasks, options).then(function formatResponse(result) {
|
|
|
|
// @TODO make this a formatResponse task?
|
2013-12-06 09:51:35 +01:00
|
|
|
if (result) {
|
2015-04-17 22:27:04 +01:00
|
|
|
return {posts: [result.toJSON(options)]};
|
2013-12-06 09:51:35 +01:00
|
|
|
}
|
2014-04-27 18:58:34 +02:00
|
|
|
|
2014-08-17 06:17:23 +00:00
|
|
|
return Promise.reject(new errors.NotFoundError('Post not found.'));
|
2013-12-06 09:51:35 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
/**
|
2015-06-22 21:11:35 +01:00
|
|
|
* ## Edit
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
* Update properties of a post
|
2014-06-03 14:05:25 +01:00
|
|
|
*
|
|
|
|
* @public
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
* @param {Post} object Post or specific properties to update
|
|
|
|
* @param {{id (required), context, include,...}} options
|
|
|
|
* @return {Promise(Post)} Edited Post
|
|
|
|
*/
|
|
|
|
edit: function edit(object, options) {
|
2015-06-22 21:11:35 +01:00
|
|
|
var tasks;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ### Handle Permissions
|
|
|
|
* We need to be an authorised user to perform this action
|
|
|
|
* @param {Object} options
|
|
|
|
* @returns {Object} options
|
|
|
|
*/
|
|
|
|
function handlePermissions(options) {
|
|
|
|
return canThis(options.context).edit.post(options.id).then(function permissionGranted() {
|
|
|
|
return options;
|
|
|
|
}).catch(function handleError(error) {
|
|
|
|
return errors.handleAPIError(error, 'You do not have permission to edit posts.');
|
|
|
|
});
|
|
|
|
}
|
2014-04-27 18:58:34 +02:00
|
|
|
|
2015-06-22 21:11:35 +01:00
|
|
|
/**
|
|
|
|
* ### Model Query
|
|
|
|
* Make the call to the Model layer
|
|
|
|
* @param {Object} options
|
|
|
|
* @returns {Object} options
|
|
|
|
*/
|
|
|
|
function modelQuery(options) {
|
|
|
|
return dataProvider.Post.edit(options.data.posts[0], _.omit(options, ['data']));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Push all of our tasks into a `tasks` array in the correct order
|
|
|
|
tasks = [utils.validate(docName), handlePermissions, utils.convertOptions(allowedIncludes), modelQuery];
|
|
|
|
|
|
|
|
// Pipeline calls each task passing the result of one to be the arguments for the next
|
|
|
|
return pipeline(tasks, object, options).then(function formatResponse(result) {
|
|
|
|
if (result) {
|
|
|
|
var post = result.toJSON(options);
|
|
|
|
|
|
|
|
// If previously was not published and now is (or vice versa), signal the change
|
|
|
|
post.statusChanged = false;
|
|
|
|
if (result.updated('status') !== result.get('status')) {
|
|
|
|
post.statusChanged = true;
|
2013-12-06 09:51:35 +01:00
|
|
|
}
|
2015-06-22 21:11:35 +01:00
|
|
|
return {posts: [post]};
|
|
|
|
}
|
2014-04-27 18:58:34 +02:00
|
|
|
|
2015-06-22 21:11:35 +01:00
|
|
|
return Promise.reject(new errors.NotFoundError('Post not found.'));
|
2013-12-06 09:51:35 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
/**
|
2015-06-22 21:11:35 +01:00
|
|
|
* ## Add
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
* Create a new post along with any tags
|
2014-06-03 14:05:25 +01:00
|
|
|
*
|
|
|
|
* @public
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
* @param {Post} object
|
|
|
|
* @param {{context, include,...}} options
|
|
|
|
* @return {Promise(Post)} Created Post
|
|
|
|
*/
|
|
|
|
add: function add(object, options) {
|
2015-06-22 21:11:35 +01:00
|
|
|
var tasks;
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
|
2015-06-22 21:11:35 +01:00
|
|
|
/**
|
|
|
|
* ### Handle Permissions
|
|
|
|
* We need to be an authorised user to perform this action
|
|
|
|
* @param {Object} options
|
|
|
|
* @returns {Object} options
|
|
|
|
*/
|
|
|
|
function handlePermissions(options) {
|
|
|
|
return canThis(options.context).add.post().then(function permissionGranted() {
|
|
|
|
return options;
|
|
|
|
}).catch(function () {
|
|
|
|
return Promise.reject(new errors.NoPermissionError('You do not have permission to add posts.'));
|
|
|
|
});
|
|
|
|
}
|
2014-05-02 17:03:26 +02:00
|
|
|
|
2015-06-22 21:11:35 +01:00
|
|
|
/**
|
|
|
|
* ### Model Query
|
|
|
|
* Make the call to the Model layer
|
|
|
|
* @param {Object} options
|
|
|
|
* @returns {Object} options
|
|
|
|
*/
|
|
|
|
function modelQuery(options) {
|
|
|
|
return dataProvider.Post.add(options.data.posts[0], _.omit(options, ['data']));
|
|
|
|
}
|
2014-05-06 12:14:58 +02:00
|
|
|
|
2015-06-22 21:11:35 +01:00
|
|
|
// Push all of our tasks into a `tasks` array in the correct order
|
|
|
|
tasks = [utils.validate(docName), handlePermissions, utils.convertOptions(allowedIncludes), modelQuery];
|
|
|
|
|
|
|
|
// Pipeline calls each task passing the result of one to be the arguments for the next
|
|
|
|
return pipeline(tasks, object, options).then(function formatResponse(result) {
|
|
|
|
var post = result.toJSON(options);
|
|
|
|
|
|
|
|
if (post.status === 'published') {
|
|
|
|
// When creating a new post that is published right now, signal the change
|
|
|
|
post.statusChanged = true;
|
|
|
|
}
|
|
|
|
return {posts: [post]};
|
2013-12-06 09:51:35 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
/**
|
2015-06-22 21:11:35 +01:00
|
|
|
* ## Destroy
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
* Delete a post, cleans up tag relations, but not unused tags
|
2014-06-03 14:05:25 +01:00
|
|
|
*
|
|
|
|
* @public
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
* @param {{id (required), context,...}} options
|
|
|
|
* @return {Promise(Post)} Deleted Post
|
|
|
|
*/
|
|
|
|
destroy: function destroy(options) {
|
2015-06-22 21:11:35 +01:00
|
|
|
var tasks;
|
2014-04-21 20:04:30 -05:00
|
|
|
|
2015-06-22 21:11:35 +01:00
|
|
|
/**
|
|
|
|
* ### Handle Permissions
|
|
|
|
* We need to be an authorised user to perform this action
|
|
|
|
* @param {Object} options
|
|
|
|
* @returns {Object} options
|
|
|
|
*/
|
|
|
|
function handlePermissions(options) {
|
|
|
|
return canThis(options.context).destroy.post(options.id).then(function permissionGranted() {
|
|
|
|
options.status = 'all';
|
|
|
|
return options;
|
|
|
|
}).catch(function handleError(error) {
|
|
|
|
return errors.handleAPIError(error, 'You do not have permission to remove posts.');
|
|
|
|
});
|
|
|
|
}
|
2014-04-21 20:04:30 -05:00
|
|
|
|
2015-06-22 21:11:35 +01:00
|
|
|
/**
|
|
|
|
* ### Model Query
|
|
|
|
* Make the call to the Model layer
|
|
|
|
* @param {Object} options
|
|
|
|
* @returns {Object} options
|
|
|
|
*/
|
|
|
|
function modelQuery(options) {
|
|
|
|
return posts.read(options).then(function (result) {
|
|
|
|
return dataProvider.Post.destroy(options).then(function () {
|
|
|
|
return result;
|
2013-12-06 09:51:35 +01:00
|
|
|
});
|
|
|
|
});
|
2015-06-22 21:11:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Push all of our tasks into a `tasks` array in the correct order
|
|
|
|
tasks = [utils.validate(docName), handlePermissions, utils.convertOptions(allowedIncludes), modelQuery];
|
|
|
|
|
|
|
|
// Pipeline calls each task passing the result of one to be the arguments for the next
|
|
|
|
return pipeline(tasks, options).then(function formatResponse(result) {
|
|
|
|
var deletedObj = result;
|
|
|
|
|
|
|
|
if (deletedObj.posts) {
|
|
|
|
_.each(deletedObj.posts, function (post) {
|
|
|
|
post.statusChanged = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return deletedObj;
|
2013-12-06 09:51:35 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-09-10 00:06:24 -04:00
|
|
|
module.exports = posts;
|