mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-03 11:01:20 +01:00
refactor: shorter check
This commit is contained in:
@@ -181,15 +181,13 @@ async function fireActionHook(hook, hookList, params) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const hookObj of hookList) {
|
for (const hookObj of hookList) {
|
||||||
if (!isHookValid(hook, hookObj)) {
|
if (isHookValid(hook, hookObj)) {
|
||||||
continue;
|
try {
|
||||||
}
|
// eslint-disable-next-line
|
||||||
|
await hookObj.method(params);
|
||||||
try {
|
} catch (err) {
|
||||||
// eslint-disable-next-line
|
winston.error(`[plugins] Error in hook ${hookObj.id}@${hookObj.hook} \n${err.stack}`);
|
||||||
await hookObj.method(params);
|
}
|
||||||
} catch (err) {
|
|
||||||
winston.error(`[plugins] Error in hook ${hookObj.id}@${hookObj.hook} \n${err.stack}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,16 +253,14 @@ async function fireResponseHook(hook, hookList, params) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const hookObj of hookList) {
|
for (const hookObj of hookList) {
|
||||||
if (!isHookValid(hook, hookObj)) {
|
if (isHookValid(hook, hookObj)) {
|
||||||
continue;
|
// Skip remaining hooks if headers have been sent
|
||||||
}
|
if (params.res.headersSent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Skip remaining hooks if headers have been sent
|
// eslint-disable-next-line no-await-in-loop
|
||||||
if (params.res.headersSent) {
|
await hookObj.method(params);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-await-in-loop
|
|
||||||
await hookObj.method(params);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user