fix: remove caller from payload after hooks is done

only if it was added automatically
isekai-main
Barış Soner Uşaklı 3 years ago
parent c18678cef2
commit 15f9aaa6ee

@ -96,9 +96,11 @@ Hooks.fire = async function (hook, params) {
winston.warn(`[plugins] Unknown hookType: ${hookType}, hook : ${hook}`);
return;
}
let deleteCaller = false;
if (params && typeof params === 'object' && !params.hasOwnProperty('caller')) {
const als = require('../als');
params.caller = als.getStore();
deleteCaller = true;
}
const result = await hookTypeToMethod[hookType](hook, hookList, params);
@ -107,6 +109,9 @@ Hooks.fire = async function (hook, params) {
Hooks.fire('action:plugins.firehook', payload);
}
if (result !== undefined) {
if (deleteCaller) {
delete result.caller;
}
return result;
}
};

Loading…
Cancel
Save