|
|
@ -2,6 +2,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
var async = require('async'),
|
|
|
|
var async = require('async'),
|
|
|
|
validator = require('validator'),
|
|
|
|
validator = require('validator'),
|
|
|
|
|
|
|
|
_ = require('underscore'),
|
|
|
|
db = require('../database'),
|
|
|
|
db = require('../database'),
|
|
|
|
topics = require('../topics'),
|
|
|
|
topics = require('../topics'),
|
|
|
|
user = require('../user'),
|
|
|
|
user = require('../user'),
|
|
|
@ -20,6 +21,7 @@ module.exports = function(Posts) {
|
|
|
|
Posts.edit = function(data, callback) {
|
|
|
|
Posts.edit = function(data, callback) {
|
|
|
|
var now = Date.now();
|
|
|
|
var now = Date.now();
|
|
|
|
var postData;
|
|
|
|
var postData;
|
|
|
|
|
|
|
|
var results;
|
|
|
|
|
|
|
|
|
|
|
|
async.waterfall([
|
|
|
|
async.waterfall([
|
|
|
|
function (next) {
|
|
|
|
function (next) {
|
|
|
@ -49,34 +51,34 @@ module.exports = function(Posts) {
|
|
|
|
updateData.handle = data.handle;
|
|
|
|
updateData.handle = data.handle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Posts.setPostFields(data.pid, updateData, next);
|
|
|
|
Posts.setPostFields(data.pid, updateData, next);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
], function(err, result) {
|
|
|
|
function (next) {
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return callback(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async.parallel({
|
|
|
|
async.parallel({
|
|
|
|
editor: function(next) {
|
|
|
|
editor: function(next) {
|
|
|
|
user.getUserFields(data.uid, ['username', 'userslug'], next);
|
|
|
|
user.getUserFields(data.uid, ['username', 'userslug'], next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
topic: function(next) {
|
|
|
|
topic: function(next) {
|
|
|
|
editMainPost(data, postData, next);
|
|
|
|
editMainPost(data, postData, next);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
post: function(next) {
|
|
|
|
function (_results, next) {
|
|
|
|
|
|
|
|
results = _results;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
postData.cid = results.topic.cid;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins.fireHook('action:post.edit', _.clone(postData));
|
|
|
|
|
|
|
|
|
|
|
|
cache.del(postData.pid);
|
|
|
|
cache.del(postData.pid);
|
|
|
|
pubsub.publish('post:edit', postData.pid);
|
|
|
|
pubsub.publish('post:edit', postData.pid);
|
|
|
|
|
|
|
|
|
|
|
|
Posts.parsePost(postData, next);
|
|
|
|
Posts.parsePost(postData, next);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
function (postData, next) {
|
|
|
|
|
|
|
|
results.post = postData;
|
|
|
|
|
|
|
|
next(null, results);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, function(err, results) {
|
|
|
|
], callback);
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return callback(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
postData.cid = results.topic.cid;
|
|
|
|
|
|
|
|
plugins.fireHook('action:post.edit', postData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback(null, results);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function editMainPost(data, postData, callback) {
|
|
|
|
function editMainPost(data, postData, callback) {
|
|
|
|