]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
app_directory: Add a 'skip call' option.
authorMike Bradeen <mbradeen@sangoma.com>
Fri, 27 Jan 2023 20:23:59 +0000 (13:23 -0700)
committerGeorge Joseph <gjoseph@digium.com>
Mon, 27 Feb 2023 19:41:03 +0000 (13:41 -0600)
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
doc/CHANGES-staging/app_directory_skip_call.txt [new file with mode: 0644]

index 847710b7a6cdd9d0c939267dfc2bcc8f47514a18..40f78966cd618d46d78f0ccaf841dc4974622e03 100644 (file)
                                                <para>Load the specified config file instead of voicemail.conf</para>
                                                <argument name="filename" required="true" />
                                        </option>
+                                       <option name="s">
+                                               <para>Skip calling the extension, instead set it in the <variable>DIRECTORY_EXTEN</variable>
+                                               channel variable.</para>
+                                       </option>
                                </optionlist>
                                <note><para>Only one of the <replaceable>f</replaceable>, <replaceable>l</replaceable>, or <replaceable>b</replaceable>
                                options may be specified. <emphasis>If more than one is specified</emphasis>, then Directory will act as
                        received and the extension to jump to exists:</para>
                        <para><literal>0</literal> - Jump to the 'o' extension, if it exists.</para>
                        <para><literal>*</literal> - Jump to the 'a' extension, if it exists.</para>
-                       <para>This application will set the following channel variable before completion:</para>
+                       <para>This application will set the following channel variables before completion:</para>
                        <variablelist>
                                <variable name="DIRECTORY_RESULT">
                                        <para>Reason Directory application exited.</para>
                                        <value name="USEREXIT">User exited with '#' during selection</value>
                                        <value name="FAILED">The application failed</value>
                                </variable>
+                               <variable name="DIRECTORY_EXTEN">
+                                       <para>If the skip calling option is set this will be set to the selected extension
+                                       provided one is selected.</para>
+                               </variable>
                        </variablelist>
                </description>
        </application>
@@ -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 (file)
index 0000000..83687fe
--- /dev/null
@@ -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.