From 1ee7176ad8f10897d25bed479da211dbc51c8ae9 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Mon, 25 Sep 2017 18:35:20 +0200 Subject: Handle no JSON query object argument passed Change-Id: I58204bbee78a16bf6843d395c18190d0e375261a Signed-off-by: Romain Forlot --- controller/ctl-action.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'controller') diff --git a/controller/ctl-action.c b/controller/ctl-action.c index 8e2db1a..8955adc 100644 --- a/controller/ctl-action.c +++ b/controller/ctl-action.c @@ -33,10 +33,16 @@ int ActionExecOne(CtlActionT* action, json_object *queryJ) { { json_object *returnJ; - // if query is empty increment usage count and pass args + // if query is empty increment usage count and pass args else + // create new JSON object if (!queryJ || json_object_get_type(queryJ) != json_type_object) { - json_object_get(action->argsJ); - queryJ = action->argsJ; + if(action->argsJ) { + json_object_get(action->argsJ); + queryJ = action->argsJ; + } + else { + queryJ = json_object_new_object(); + } } else if (action->argsJ) { // Merge queryJ and argsJ before sending request @@ -49,7 +55,6 @@ int ActionExecOne(CtlActionT* action, json_object *queryJ) { json_object_object_add(queryJ, "args", action->argsJ); } } - json_object_object_add(queryJ, "label", json_object_new_string(action->source.label)); int err = afb_service_call_sync(action->api, action->call, queryJ, &returnJ); -- cgit 1.2.3-korg