summaryrefslogtreecommitdiffstats
path: root/controller
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-09-25 18:35:20 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-14 11:00:25 +0100
commit1ee7176ad8f10897d25bed479da211dbc51c8ae9 (patch)
tree5cee4c433aea9fbe5fd509615dc4ab76dcb53a29 /controller
parent58149e03533adad2c35bb5914efab086c3bc3d78 (diff)
Handle no JSON query object argument passed
Change-Id: I58204bbee78a16bf6843d395c18190d0e375261a Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'controller')
-rw-r--r--controller/ctl-action.c13
1 files changed, 9 insertions, 4 deletions
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);