Skip to content

Commit 54700ae

Browse files
committed
deepscan new issues
1 parent c661d65 commit 54700ae

File tree

1 file changed

+31
-33
lines changed

1 file changed

+31
-33
lines changed

plugins/hooks/api/api.js

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -290,31 +290,31 @@ plugins.register("/i/hook/save", function(ob) {
290290
common.returnMessage(params, 400, 'Not enough args');
291291
return true;
292292
}
293-
294293

295-
if (hookConfig.effects && !validateEffects(hookConfig.effects)) {
296-
common.returnMessage(params, 400, 'Invalid configuration for effects');
297-
return true;
298-
}
299294

300-
if (hookConfig._id) {
301-
const id = hookConfig._id;
302-
delete hookConfig._id;
303-
return common.db.collection("hooks").findAndModify(
304-
{ _id: common.db.ObjectID(id) },
305-
{},
306-
{$set: hookConfig},
307-
{new: true},
308-
function(err, result) {
309-
if (!err) {
310-
common.returnOutput(params, result && result.value);
311-
}
312-
else {
313-
common.returnMessage(params, 500, "Failed to save an hook");
314-
}
315-
});
295+
if (hookConfig.effects && !validateEffects(hookConfig.effects)) {
296+
common.returnMessage(params, 400, 'Invalid configuration for effects');
297+
return true;
298+
}
299+
300+
if (hookConfig._id) {
301+
const id = hookConfig._id;
302+
delete hookConfig._id;
303+
return common.db.collection("hooks").findAndModify(
304+
{ _id: common.db.ObjectID(id) },
305+
{},
306+
{$set: hookConfig},
307+
{new: true},
308+
function(err, result) {
309+
if (!err) {
310+
common.returnOutput(params, result && result.value);
311+
}
312+
else {
313+
common.returnMessage(params, 500, "Failed to save an hook");
314+
}
315+
});
316+
}
316317
}
317-
}
318318
hookConfig.createdBy = params.member._id;
319319
hookConfig.created_at = new Date().getTime();
320320
return common.db.collection("hooks").insert(
@@ -587,7 +587,7 @@ plugins.register("/i/hook/test", function(ob) {
587587

588588
if (hookConfig) {
589589
// Null check for hookConfig
590-
if (hookConfigEffects && !validateEffects(hookConfigEffects)) {
590+
if (hookConfig.effects && !validateEffects(hookConfig.effects)) {
591591
common.returnMessage(params, 400, 'Config invalid');
592592
}
593593
}
@@ -597,16 +597,14 @@ plugins.register("/i/hook/test", function(ob) {
597597
const results = [];
598598

599599
// build mock data
600-
if(hookConfig){
601-
const trigger = hookConfig?.trigger;
602-
hookConfig._id = null;
603-
log.d("[hook test mock data]", mockData);
604-
const obj = {
605-
is_mock: true,
606-
params: mockData,
607-
rule: hookConfig
608-
};
609-
}
600+
const trigger = hookConfig?.trigger;
601+
hookConfig._id = null;
602+
log.d("[hook test mock data]", mockData);
603+
const obj = {
604+
is_mock: true,
605+
params: mockData,
606+
rule: hookConfig
607+
};
610608
log.d("[hook test config data]", obj);
611609
const t = new Triggers[trigger.type]({
612610
rules: [hookConfig],

0 commit comments

Comments
 (0)