From d813bda88379be18d315f7c1e2515f977cad70de Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 15 Jan 2015 11:19:38 -0500 Subject: [PATCH] update, create, destroy hooks, #2609 --- src/groups.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/groups.js b/src/groups.js index 53943bf893..709aaeda05 100644 --- a/src/groups.js +++ b/src/groups.js @@ -428,7 +428,15 @@ var async = require('async'), tasks.push(async.apply(db.setAdd, 'group:' + data.name + ':members', data.ownerUid)); } - async.parallel(tasks, callback); + async.parallel(tasks, function(err) { + if (!err) { + plugins.fireHook('action:group.create', { + name: data.name + }); + } + + callback(err); + }); }); }; @@ -458,7 +466,7 @@ var async = require('async'), return callback(err); } - plugins.fireHook('action:group.updated', { + plugins.fireHook('action:group.update', { name: groupName, values: payload }); @@ -564,7 +572,15 @@ var async = require('async'), }, next); }); } - ], callback); + ], function(err) { + if (!err) { + plugins.fireHook('action:group.destroy', { + name: groupName + }); + } + + callback(err); + }); }; Groups.join = function(groupName, uid, callback) {