From dff1a04585d550906f404f361274997dc4bf0f4a Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 19 Jun 2015 15:39:33 -0400 Subject: [PATCH] more category hooks --- src/categories/create.js | 1 + src/categories/delete.js | 6 +++++- src/categories/update.js | 8 +++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/categories/create.js b/src/categories/create.js index 4895e98c34..1b47f87760 100644 --- a/src/categories/create.js +++ b/src/categories/create.js @@ -54,6 +54,7 @@ module.exports = function(Categories) { ], next); }, function(results, next) { + plugins.fireHook('action:category.create', category); next(null, category); } ], callback); diff --git a/src/categories/delete.js b/src/categories/delete.js index 0ebac949d7..1679ab6731 100644 --- a/src/categories/delete.js +++ b/src/categories/delete.js @@ -3,6 +3,7 @@ var async = require('async'), db = require('../database'), batch = require('../batch'), + plugins = require('../plugins'), threadTools = require('../threadTools'); @@ -17,7 +18,10 @@ module.exports = function(Categories) { if (err) { return callback(err); } - purgeCategory(cid, callback); + async.series([ + async.apply(purgeCategory, cid), + async.apply(plugins.fireHook, 'action:category.delete', cid) + ], callback); }); }; diff --git a/src/categories/update.js b/src/categories/update.js index 6fcf7d4b57..f1d9ee773c 100644 --- a/src/categories/update.js +++ b/src/categories/update.js @@ -20,7 +20,13 @@ module.exports = function(Categories) { var fields = Object.keys(category); async.each(fields, function(key, next) { updateCategoryField(cid, key, category[key], next); - }, next); + }, function(err) { + if (err) { + return next(err); + } + plugins.fireHook('action:category.update', {cid: cid, modified: category}); + next(); + }); }); }); }