[Asterisk-code-review] app_voicemail: Throw warning if asking for nonexistent mailbox. (asterisk[master])

N A asteriskteam at digium.com
Wed Feb 16 05:37:32 CST 2022


N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/18016 )


Change subject: app_voicemail: Throw warning if asking for nonexistent mailbox.
......................................................................

app_voicemail: Throw warning if asking for nonexistent mailbox.

Currently, if VoiceMailMain is called with a mailbox, if that
mailbox doesn't exist, then the application silently falls back
to prompting the user for the mailbox, as if no arguments were
provided.

However, if a specific mailbox is requested and it doesn't exist,
then no warning at all is emitted.

This fixes this behavior to now warn the user if a specifically
requested mailbox could not be accessed, before falling back to
prompting the user for the correct mailbox.

ASTERISK-29920 #close

Change-Id: Ib4093b88cd661a2cabc5d685777d4e2f0ebd20a4
---
M apps/app_voicemail.c
1 file changed, 16 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/16/18016/1

diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 6dec471..a7d51ec 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -11504,22 +11504,31 @@
 
 		valid = ast_test_flag(&flags, OPT_SILENT);
 
-		if ((context = strchr(args.argv0, '@')))
+		if ((context = strchr(args.argv0, '@'))) {
 			*context++ = '\0';
+		}
 
-		if (ast_test_flag(&flags, OPT_PREPEND_MAILBOX))
+		if (ast_test_flag(&flags, OPT_PREPEND_MAILBOX)) {
 			ast_copy_string(prefixstr, args.argv0, sizeof(prefixstr));
-		else
+		} else {
 			ast_copy_string(vms.username, args.argv0, sizeof(vms.username));
+		}
 
-		if (!ast_strlen_zero(vms.username) && (vmu = find_user(&vmus, context ,vms.username)))
-			skipuser++;
-		else
+		if (!ast_strlen_zero(vms.username)) {
+			if ((vmu = find_user(&vmus, context ,vms.username))) {
+				skipuser++;
+			} else {
+				ast_log(LOG_WARNING, "Mailbox '%s%s%s' doesn't exist\n", vms.username, context ? "@": "", context ? context : "");
+				valid = 0;
+			}
+		} else {
 			valid = 0;
+		}
 	}
 
-	if (!valid)
+	if (!valid) {
 		res = vm_authenticate(chan, vms.username, sizeof(vms.username), &vmus, context, prefixstr, skipuser, maxlogins, 0);
+	}
 
 	ast_debug(1, "After vm_authenticate\n");
 

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18016
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ib4093b88cd661a2cabc5d685777d4e2f0ebd20a4
Gerrit-Change-Number: 18016
Gerrit-PatchSet: 1
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220216/5add3cc4/attachment-0001.html>


More information about the asterisk-code-review mailing list