struct ast_ari_response *response)
{
RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
+ int ipri;
+ const char *context;
+ const char *exten;
ast_assert(response != NULL);
return;
}
- if (stasis_app_control_continue(control, args->context, args->extension, args->priority)) {
+ snapshot = stasis_app_control_get_snapshot(control);
+ if (!snapshot) {
+ return;
+ }
+
+ if (ast_strlen_zero(args->context)) {
+ context = snapshot->context;
+ exten = S_OR(args->extension, snapshot->exten);
+ } else {
+ context = args->context;
+ exten = S_OR(args->extension, "s");
+ }
+
+ if (!ast_strlen_zero(args->label)) {
+ /* A label was provided in the request, use that */
+
+ if (sscanf(args->label, "%30d", &ipri) != 1) {
+ ipri = ast_findlabel_extension(NULL, context, exten, args->label, NULL);
+ if (ipri == -1) {
+ ast_log(AST_LOG_ERROR, "Requested label: %s can not be found in context: %s\n", args->label, context);
+ ast_ari_response_error(response, 404, "Not Found", "Requested label can not be found");
+ return;
+ }
+ } else {
+ ast_debug(3, "Numeric value provided for label, jumping to that priority\n");
+ }
+
+ if (ipri == 0) {
+ ast_log(AST_LOG_ERROR, "Invalid priority label '%s' specified for extension %s in context: %s\n",
+ args->label, exten, context);
+ ast_ari_response_error(response, 400, "Bad Request", "Requested priority is illegal");
+ return;
+ }
+
+ } else if (args->priority) {
+ /* No label provided, use provided priority */
+ ipri = args->priority;
+ } else if (ast_strlen_zero(args->context) && ast_strlen_zero(args->extension)) {
+ /* Special case. No exten, context, or priority provided, then move on to the next priority */
+ ipri = snapshot->priority + 1;
+ } else {
+ ipri = 1;
+ }
+
+
+ if (stasis_app_control_continue(control, context, exten, ipri)) {
ast_ari_response_alloc_failed(response);
return;
}
const char *args_extension,
const char *args_context,
long args_priority,
+ const char *args_label,
const char *args_app,
const char *args_app_args,
const char *args_caller_id,
ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT), ao2_cleanup);
char *stuff;
struct ast_channel *other = NULL;
- struct ast_channel *chan;
+ struct ast_channel *chan = NULL;
RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
struct ast_assigned_ids assignedids = {
.uniqueid = args_channel_id,
ast_copy_string(origination->context, S_OR(args_context, "default"), sizeof(origination->context));
ast_copy_string(origination->exten, args_extension, sizeof(origination->exten));
- origination->priority = args_priority ? args_priority : 1;
+
+ if (!ast_strlen_zero(args_label)) {
+ /* A label was provided in the request, use that */
+ int ipri = 1;
+ if (sscanf(args_label, "%30d", &ipri) != 1) {
+ ipri = ast_findlabel_extension(chan, origination->context, origination->exten, args_label, args_caller_id);
+
+ if (ipri == -1) {
+ ast_log(AST_LOG_ERROR, "Requested label: %s can not be found in context: %s\n", args_label, args_context);
+ ast_ari_response_error(response, 404, "Not Found", "Requested label can not be found");
+ return;
+ }
+ } else {
+ ast_debug(3, "Numeric value provided for label, jumping to that priority\n");
+ }
+
+ if (ipri == 0) {
+ ast_log(AST_LOG_ERROR, "Invalid priority label '%s' specified for extension %s in context: %s\n",
+ args_label, args_extension, args_context);
+ ast_ari_response_error(response, 400, "Bad Request", "Requested priority is illegal");
+ return;
+ }
+
+ /* Our priority was provided by a label */
+ origination->priority = ipri;
+ } else {
+ /* No label provided, use provided priority */
+ origination->priority = args_priority ? args_priority : 1;
+ }
+
origination->appdata[0] = '\0';
} else {
ast_ari_response_error(response, 400, "Bad Request",
args->extension,
args->context,
args->priority,
+ args->label,
args->app,
args->app_args,
args->caller_id,
args->extension,
args->context,
args->priority,
+ args->label,
args->app,
args->app_args,
args->caller_id,
if (field) {
args->priority = ast_json_integer_get(field);
}
+ field = ast_json_object_get(body, "label");
+ if (field) {
+ args->label = ast_json_string_get(field);
+ }
field = ast_json_object_get(body, "app");
if (field) {
args->app = ast_json_string_get(field);
if (strcmp(i->name, "priority") == 0) {
args.priority = atol(i->value);
} else
+ if (strcmp(i->name, "label") == 0) {
+ args.label = (i->value);
+ } else
if (strcmp(i->name, "app") == 0) {
args.app = (i->value);
} else
if (field) {
args->priority = ast_json_integer_get(field);
}
+ field = ast_json_object_get(body, "label");
+ if (field) {
+ args->label = ast_json_string_get(field);
+ }
field = ast_json_object_get(body, "app");
if (field) {
args->app = ast_json_string_get(field);
if (strcmp(i->name, "priority") == 0) {
args.priority = atol(i->value);
} else
+ if (strcmp(i->name, "label") == 0) {
+ args.label = (i->value);
+ } else
if (strcmp(i->name, "app") == 0) {
args.app = (i->value);
} else
if (field) {
args->priority = ast_json_integer_get(field);
}
+ field = ast_json_object_get(body, "label");
+ if (field) {
+ args->label = ast_json_string_get(field);
+ }
return 0;
}
if (strcmp(i->name, "priority") == 0) {
args.priority = atoi(i->value);
} else
+ if (strcmp(i->name, "label") == 0) {
+ args.label = (i->value);
+ } else
{}
}
for (i = path_vars; i; i = i->next) {