+ if(event)
+ {
+ if (json_object_get_type(event) != json_type_array) // event is set before and check if it's an array
+ {
+ rc = one_subscribe_unsubscribe_events(request, subscribe, json_object_get_string(event), args);
+ }
+ else // event is set and it's not an array
+ {
+ for (int i = 0 ; i < json_object_array_length(event); i++)
+ {
+ x = json_object_array_get_idx(event, i);
+ rc2 = one_subscribe_unsubscribe_events(request, subscribe, json_object_get_string(x), args);
+ if (rc >= 0)
+ rc = rc2 >= 0 ? rc + rc2 : rc2;
+ }
+ }
+ }
+
+ if(id)
+ {
+ if (json_object_get_type(id) != json_type_array) // id is set before and check if it's an array
+ {
+ rc = one_subscribe_unsubscribe_id(request, subscribe, json_object_get_int(id), args);
+ }
+ else // event is set and it's not an array
+ {
+ for (int i = 0 ; i < json_object_array_length(id); i++)
+ {
+ x = json_object_array_get_idx(id, i);
+ rc2 = one_subscribe_unsubscribe_id(request, subscribe, json_object_get_int(x), args);
+ if (rc >= 0)
+ rc = rc2 >= 0 ? rc + rc2 : rc2;
+ }
+ }
+ }
+ }
+ return rc;
+}
+
+static void do_subscribe_unsubscribe(afb_req_t request, bool subscribe)
+{
+ int rc = 0;
+ struct json_object *args, *x;
+
+ args = afb_req_json(request);
+ if (json_object_get_type(args) == json_type_array)
+ {
+ for(int i = 0; i < json_object_array_length(args); i++)