From 3b75e6d45e3ad7d2ea8fcc47966ff7c8a21b0432 Mon Sep 17 00:00:00 2001 From: Mike Bradeen Date: Fri, 27 Jan 2023 13:23:59 -0700 Subject: [PATCH] app_directory: Add a 'skip call' option. Adds 's' option to skip calling the extension and instead set the extension as DIRECTORY_EXTEN channel variable. ASTERISK-30405 Change-Id: Ib9d9db1ba5b7524594c640461b4aa8f752db8299 --- apps/app_directory.c | 15 ++++++++++++++- doc/CHANGES-staging/app_directory_skip_call.txt | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 doc/CHANGES-staging/app_directory_skip_call.txt diff --git a/apps/app_directory.c b/apps/app_directory.c index 847710b7a6..40f78966cd 100644 --- a/apps/app_directory.c +++ b/apps/app_directory.c @@ -107,6 +107,10 @@ Load the specified config file instead of voicemail.conf + Only one of the f, l, or b options may be specified. If more than one is specified, then Directory will act as @@ -123,7 +127,7 @@ received and the extension to jump to exists: 0 - Jump to the 'o' extension, if it exists. * - Jump to the 'a' extension, if it exists. - This application will set the following channel variable before completion: + This application will set the following channel variables before completion: Reason Directory application exited. @@ -135,6 +139,10 @@ User exited with '#' during selection The application failed + + If the skip calling option is set this will be set to the selected extension + provided one is selected. + @@ -158,6 +166,7 @@ enum { OPT_NOANSWER = (1 << 6), OPT_ALIAS = (1 << 7), OPT_CONFIG_FILE = (1 << 8), + OPT_SKIP = (1 << 9), }; enum { @@ -190,6 +199,7 @@ AST_APP_OPTIONS(directory_app_options, { AST_APP_OPTION('n', OPT_NOANSWER), AST_APP_OPTION('a', OPT_ALIAS), AST_APP_OPTION_ARG('c', OPT_CONFIG_FILE, OPT_ARG_FILENAME), + AST_APP_OPTION('s', OPT_SKIP), }); static int compare(const char *text, const char *template) @@ -325,6 +335,9 @@ static int select_entry(struct ast_channel *chan, const char *dialcontext, const if (ast_test_flag(flags, OPT_FROMVOICEMAIL)) { /* We still want to set the exten though */ ast_channel_exten_set(chan, item->exten); + } else if (ast_test_flag(flags, OPT_SKIP)) { + /* Skip calling the extension, only set it in the channel variable. */ + pbx_builtin_setvar_helper(chan, "DIRECTORY_EXTEN", item->exten); } else if (ast_goto_if_exists(chan, S_OR(dialcontext, item->context), item->exten, 1)) { ast_log(LOG_WARNING, "Can't find extension '%s' in context '%s'. " diff --git a/doc/CHANGES-staging/app_directory_skip_call.txt b/doc/CHANGES-staging/app_directory_skip_call.txt new file mode 100644 index 0000000000..83687fe3f9 --- /dev/null +++ b/doc/CHANGES-staging/app_directory_skip_call.txt @@ -0,0 +1,5 @@ +Subject: app_directory + +A new option 's' has been added to the Directory() application that +will skip calling the extension and instead set the extension as +DIRECTORY_EXTEN channel variable.