Skip to content

Commit

Permalink
[hooks] fix obj deepclone bug
Browse files Browse the repository at this point in the history
  • Loading branch information
waiterZen committed Nov 29, 2021
1 parent 134d3be commit 434dc75
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions plugins/hooks/api/parts/triggers/incoming_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,35 @@ class IncomingDataTrigger {
register() {
InternalEvents.forEach((e) => {
plugins.register(e, (obj) => {
const ob = Object.assign({}, obj);
console.log(e, ob, "?##33333433");
if (e === '/plugins/drill') {
const hooksData = {
params: {...ob.params}
try {
const ob = {
params: {
app_user: JSON.parse(JSON.stringify(obj.params.app_user)),
app_id: common.db.ObjectID(obj.params.app_id.toString()),
req: {
header: JSON.parse(JSON.stringify(obj.params.req.headers||{})),
},
ip_address: obj.params.ip_address,
qstring: JSON.parse(JSON.stringify(obj.params.qstring || {})),
},
events: JSON.parse(JSON.stringify(obj.events || [])),
};
if (ob.events) {
hooksData.params.qstring.events = ob.events;
log.d(e, ob, "[Incoming data capture]");
if (e === '/plugins/drill') {
const hooksData = {
params: {...ob.params}
};
if (ob.events) {
hooksData.params.qstring.events = ob.events;
}
this.process(e, hooksData);
return;
}
this.process(e, hooksData);
return;
this.process(e, ob);
} catch (err) {
console.log(err);
}
this.process(e, ob);

});
});
}
Expand Down

0 comments on commit 434dc75

Please sign in to comment.