mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-20 23:40:38 +01:00
fix: remove caller from payload after hooks is done
only if it was added automatically
This commit is contained in:
@@ -96,9 +96,11 @@ Hooks.fire = async function (hook, params) {
|
|||||||
winston.warn(`[plugins] Unknown hookType: ${hookType}, hook : ${hook}`);
|
winston.warn(`[plugins] Unknown hookType: ${hookType}, hook : ${hook}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let deleteCaller = false;
|
||||||
if (params && typeof params === 'object' && !params.hasOwnProperty('caller')) {
|
if (params && typeof params === 'object' && !params.hasOwnProperty('caller')) {
|
||||||
const als = require('../als');
|
const als = require('../als');
|
||||||
params.caller = als.getStore();
|
params.caller = als.getStore();
|
||||||
|
deleteCaller = true;
|
||||||
}
|
}
|
||||||
const result = await hookTypeToMethod[hookType](hook, hookList, params);
|
const result = await hookTypeToMethod[hookType](hook, hookList, params);
|
||||||
|
|
||||||
@@ -107,6 +109,9 @@ Hooks.fire = async function (hook, params) {
|
|||||||
Hooks.fire('action:plugins.firehook', payload);
|
Hooks.fire('action:plugins.firehook', payload);
|
||||||
}
|
}
|
||||||
if (result !== undefined) {
|
if (result !== undefined) {
|
||||||
|
if (deleteCaller) {
|
||||||
|
delete result.caller;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user