]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Support VoiceMail d() option when extension does not exist in channel's context
authorMatthew Jordan <mjordan@digium.com>
Mon, 7 May 2012 18:36:54 +0000 (18:36 +0000)
committerMatthew Jordan <mjordan@digium.com>
Mon, 7 May 2012 18:36:54 +0000 (18:36 +0000)
The VoiceMail d([c]) option is documented to accept digits for a new extension
in context <c>, if played during the greeting.  This option works fine if the
extension being redirected to has an extension with the same initial digit in
the channel's current context.  If that digit did not happen to exist in some
extension, a dialplan match would fail and the user would not be redirected.

This patch fixes it such that if the <c> option is used, the extensions are
matched in that context as opposed to the caller's original context.

(closes issue ASTERISK-18243)
Reported by: mjordan
Tested by: mjordan

Review: https://reviewboard.asterisk.org/r/1892

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@365474 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_voicemail.c
main/pbx.c

index ff28df4ae0d4bb2605526b1eae3a59e2c1eeed5c..63b888719acedb99c9912f7c609c9a7a3fd7c27d 100644 (file)
@@ -5740,8 +5740,9 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
                        char e[2] = "";
                        e[0] = *code;
                        if (strchr(ecodes, e[0]) == NULL
-                               && ast_canmatch_extension(chan, chan->context, e, 1,
-                                       S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
+                               && ast_canmatch_extension(chan,
+                                       (!ast_strlen_zero(options->exitcontext) ? options->exitcontext : chan->context),
+                                       e, 1, S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
                                strncat(ecodes, e, sizeof(ecodes) - strlen(ecodes) - 1);
                        }
                }
@@ -5836,11 +5837,12 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
 
        /* Allow all other digits to exit Voicemail and return to the dialplan */
        if (ast_test_flag(options, OPT_DTMFEXIT) && res > 0) {
-               if (!ast_strlen_zero(options->exitcontext))
+               if (!ast_strlen_zero(options->exitcontext)) {
                        ast_copy_string(chan->context, options->exitcontext, sizeof(chan->context));
+               }
                free_user(vmu);
-               pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT");
                ast_free(tmp);
+               pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT");
                return res;
        }
 
index dbe530b268a5814a481cf114879d61b4bb944090..8767baa3fe1f371744e80c2898779befaaa91304 100644 (file)
@@ -5100,8 +5100,9 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
                 * and continue, or we can drop out entirely. */
 
                if (invalid
-                       || !ast_exists_extension(c, c->context, c->exten, 1,
-                               S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
+                       || (ast_strlen_zero(dst_exten) &&
+                               !ast_exists_extension(c, c->context, c->exten, 1,
+                               S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL)))) {
                        /*!\note
                         * If there is no match at priority 1, it is not a valid extension anymore.
                         * Try to continue at "i" (for invalid) or "e" (for exception) or exit if