don't bother firing hooks received by js unless a listener exists

This commit is contained in:
Julian Lam
2014-01-29 12:28:21 -05:00
parent 133188f14c
commit 38ee3fd5a3
2 changed files with 14 additions and 3 deletions

View File

@@ -20,8 +20,15 @@ var nconf = require('nconf'),
app.put('/plugins/fireHook', function(req, res) {
// PUT = action
plugins.fireHook('action:' + req.body.hook, req.body.args);
res.send(200);
var hook = 'action:' + req.body.hook;
if (plugins.hasListeners(hook)) {
// Hook executes
plugins.fireHook(hook, req.body.args);
res.send(200);
} else {
// No listeners for this hook
res.send(404);
}
});
// Static Assets