diff options
Diffstat (limited to 'res')
-rw-r--r-- | res/ari/resource_channels.c | 42 | ||||
-rw-r--r-- | res/ari/resource_channels.h | 2 | ||||
-rw-r--r-- | res/res_ari_channels.c | 35 |
3 files changed, 34 insertions, 45 deletions
diff --git a/res/ari/resource_channels.c b/res/ari/resource_channels.c index 667ea73f0..c6900f1b2 100644 --- a/res/ari/resource_channels.c +++ b/res/ari/resource_channels.c @@ -687,43 +687,6 @@ void ast_ari_channels_list(struct ast_variable *headers, ast_ari_response_ok(response, ast_json_ref(json)); } -static int ari_channels_set_channel_var(struct ast_channel *chan, - const char *variable, const char *value, struct ast_ari_response *response) -{ - if (pbx_builtin_setvar_helper(chan, variable, value)) { - ast_ari_response_error( - response, 400, "Bad Request", - "Unable to set channel variable %s=%s", variable, value); - return -1; - } - - return 0; -} - -static int ari_channels_set_channel_vars(struct ast_channel *chan, - struct ast_json *variables, struct ast_ari_response *response) -{ - struct ast_json_iter *i; - - if (!variables) { - /* nothing to do */ - return 0; - } - - for (i = ast_json_object_iter(variables); i; - i = ast_json_object_iter_next(variables, i)) { - if (ari_channels_set_channel_var( - chan, ast_json_object_iter_key(i), - ast_json_string_get(ast_json_object_iter_value(i)), - response)) { - /* response filled in by called function */ - return -1; - } - } - - return 0; -} - void ast_ari_channels_originate(struct ast_variable *headers, struct ast_ari_channels_originate_args *args, struct ast_ari_response *response) @@ -813,11 +776,6 @@ void ast_ari_channels_originate(struct ast_variable *headers, return; } - if (ari_channels_set_channel_vars(chan, args->variables, response)) { - /* response filled in by called function */ - return; - } - snapshot = ast_channel_snapshot_create(chan); ast_channel_unlock(chan); diff --git a/res/ari/resource_channels.h b/res/ari/resource_channels.h index 36c7339ba..49ab8eb34 100644 --- a/res/ari/resource_channels.h +++ b/res/ari/resource_channels.h @@ -68,8 +68,6 @@ struct ast_ari_channels_originate_args { const char *caller_id; /*! \brief Timeout (in seconds) before giving up dialing, or -1 for no timeout. */ int timeout; - /*! \brief Variables to be set on the channel. */ - struct ast_json *variables; }; /*! * \brief Create a new channel (originate). diff --git a/res/res_ari_channels.c b/res/res_ari_channels.c index 6b741b04c..40ad32b2b 100644 --- a/res/res_ari_channels.c +++ b/res/res_ari_channels.c @@ -117,6 +117,7 @@ static void ast_ari_channels_originate_cb( struct ast_ari_channels_originate_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; @@ -164,7 +165,39 @@ static void ast_ari_channels_originate_cb( goto fin; } } - args.variables = ast_json_ref(body); + /* Parse query parameters out of it */ + field = ast_json_object_get(body, "endpoint"); + if (field) { + args.endpoint = ast_json_string_get(field); + } + field = ast_json_object_get(body, "extension"); + if (field) { + args.extension = ast_json_string_get(field); + } + field = ast_json_object_get(body, "context"); + if (field) { + args.context = ast_json_string_get(field); + } + field = ast_json_object_get(body, "priority"); + if (field) { + args.priority = ast_json_integer_get(field); + } + field = ast_json_object_get(body, "app"); + if (field) { + args.app = ast_json_string_get(field); + } + field = ast_json_object_get(body, "appArgs"); + if (field) { + args.app_args = ast_json_string_get(field); + } + field = ast_json_object_get(body, "callerId"); + if (field) { + args.caller_id = ast_json_string_get(field); + } + field = ast_json_object_get(body, "timeout"); + if (field) { + args.timeout = ast_json_integer_get(field); + } ast_ari_channels_originate(headers, &args, response); #if defined(AST_DEVMODE) code = response->response_code; |