mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-06 10:39:44 +02:00
Merge branch 'master' into develop
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var winston = require('winston'),
|
||||
async = require('async');
|
||||
var winston = require('winston');
|
||||
var async = require('async');
|
||||
|
||||
module.exports = function (Plugins) {
|
||||
Plugins.deprecatedHooks = {
|
||||
@@ -10,7 +10,7 @@ module.exports = function (Plugins) {
|
||||
'filter:user.profileLinks': 'filter:user.profileMenu',
|
||||
'action:post.flag': 'action:flag.create',
|
||||
'action:plugin.activate': null,
|
||||
'action:plugin.install': null
|
||||
'action:plugin.install': null,
|
||||
};
|
||||
/*
|
||||
`data` is an object consisting of (* is required):
|
||||
@@ -47,7 +47,7 @@ module.exports = function (Plugins) {
|
||||
if (parts.length > 2) {
|
||||
parts.pop();
|
||||
}
|
||||
var hook = parts.join(':');
|
||||
parts.join(':');
|
||||
}
|
||||
|
||||
if (data.hook && data.method) {
|
||||
@@ -60,10 +60,9 @@ module.exports = function (Plugins) {
|
||||
method = data.method.split('.').reduce(function (memo, prop) {
|
||||
if (memo && memo[prop]) {
|
||||
return memo[prop];
|
||||
} else {
|
||||
// Couldn't find method by path, aborting
|
||||
return null;
|
||||
}
|
||||
// Couldn't find method by path, aborting
|
||||
return null;
|
||||
}, Plugins.libraries[data.id]);
|
||||
|
||||
// Write the actual method reference to the hookObj
|
||||
@@ -86,18 +85,18 @@ module.exports = function (Plugins) {
|
||||
var hookType = hook.split(':')[0];
|
||||
|
||||
switch (hookType) {
|
||||
case 'filter':
|
||||
fireFilterHook(hook, hookList, params, callback);
|
||||
break;
|
||||
case 'action':
|
||||
fireActionHook(hook, hookList, params, callback);
|
||||
break;
|
||||
case 'static':
|
||||
fireStaticHook(hook, hookList, params, callback);
|
||||
break;
|
||||
default:
|
||||
winston.warn('[plugins] Unknown hookType: ' + hookType + ', hook : ' + hook);
|
||||
break;
|
||||
case 'filter':
|
||||
fireFilterHook(hook, hookList, params, callback);
|
||||
break;
|
||||
case 'action':
|
||||
fireActionHook(hook, hookList, params, callback);
|
||||
break;
|
||||
case 'static':
|
||||
fireStaticHook(hook, hookList, params, callback);
|
||||
break;
|
||||
default:
|
||||
winston.warn('[plugins] Unknown hookType: ' + hookType + ', hook : ' + hook);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -129,7 +128,6 @@ module.exports = function (Plugins) {
|
||||
return callback();
|
||||
}
|
||||
async.each(hookList, function (hookObj, next) {
|
||||
|
||||
if (typeof hookObj.method !== 'function') {
|
||||
if (global.env === 'development') {
|
||||
winston.warn('[plugins] Expected method for hook \'' + hook + '\' in plugin \'' + hookObj.id + '\' not found, skipping.');
|
||||
@@ -163,7 +161,7 @@ module.exports = function (Plugins) {
|
||||
next.apply(null, arguments);
|
||||
}
|
||||
});
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
winston.error('[plugins] Error executing \'' + hook + '\' in plugin \'' + hookObj.id + '\'');
|
||||
winston.error(err);
|
||||
clearTimeout(timeoutId);
|
||||
|
||||
Reference in New Issue
Block a user