From 6389bc762ca18de4d3f6b91bc377618607d586a4 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 30 Jun 2014 17:33:31 -0400 Subject: [PATCH] fire post edit after hook after post is saved --- src/postTools.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/postTools.js b/src/postTools.js index e308332abe..4b129a7e23 100644 --- a/src/postTools.js +++ b/src/postTools.js @@ -40,15 +40,14 @@ var winston = require('winston'), return callback(err); } - posts.setPostFields(pid, { - edited: Date.now(), - editor: uid, - content: postData.content - }); - - events.logPostEdit(uid, pid); - async.parallel({ + post: function(next) { + posts.setPostFields(pid, { + edited: Date.now(), + editor: uid, + content: postData.content + }, next); + }, topic: function(next) { var tid = postData.tid; posts.isMain(pid, function(err, isMainPost) { @@ -74,8 +73,6 @@ var winston = require('winston'), topics.updateTags(tid, options.tags); } - plugins.fireHook('action:post.edit', postData); - next(null, { tid: tid, title: validator.escape(title), @@ -87,7 +84,15 @@ var winston = require('winston'), content: function(next) { PostTools.parse(postData.content, next); } - }, callback); + }, function(err, results) { + if (err) { + return callback(err); + } + + events.logPostEdit(uid, pid); + plugins.fireHook('action:post.edit', postData); + callback(null, results); + }); }); };