diff options
Diffstat (limited to 'res/res_ari_device_states.c')
-rw-r--r-- | res/res_ari_device_states.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/res/res_ari_device_states.c b/res/res_ari_device_states.c index a8079f139..5576a1859 100644 --- a/res/res_ari_device_states.c +++ b/res/res_ari_device_states.c @@ -160,6 +160,19 @@ static void ast_ari_device_states_get_cb( fin: __attribute__((unused)) return; } +int ast_ari_device_states_update_parse_body( + struct ast_json *body, + struct ast_ari_device_states_update_args *args) +{ + struct ast_json *field; + /* Parse query parameters out of it */ + field = ast_json_object_get(body, "deviceState"); + if (field) { + args->device_state = ast_json_string_get(field); + } + return 0; +} + /*! * \brief Parameter parsing callback for /deviceStates/{deviceName}. * \param get_params GET parameters in the HTTP request. @@ -175,7 +188,6 @@ static void ast_ari_device_states_update_cb( struct ast_ari_device_states_update_args args = {}; struct ast_variable *i; RAII_VAR(struct ast_json *, body, NULL, ast_json_unref); - struct ast_json *field; #if defined(AST_DEVMODE) int is_valid; int code; @@ -208,10 +220,9 @@ static void ast_ari_device_states_update_cb( goto fin; } } - /* Parse query parameters out of it */ - field = ast_json_object_get(body, "deviceState"); - if (field) { - args.device_state = ast_json_string_get(field); + if (ast_ari_device_states_update_parse_body(body, &args)) { + ast_ari_response_alloc_failed(response); + goto fin; } ast_ari_device_states_update(headers, &args, response); #if defined(AST_DEVMODE) |