[Asterisk-code-review] app_voicemail: Process urgent messages with mailcmd (asterisk[13])

Friendly Automation asteriskteam at digium.com
Tue Aug 25 16:38:16 CDT 2020


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/14807 )

Change subject: app_voicemail: Process urgent messages with mailcmd
......................................................................

app_voicemail: Process urgent messages with mailcmd

Rather than putting messages into INBOX and then moving them to Urgent
later, put them directly in to the Urgent folder. This prevents
mailcmd from being skipped.

ASTERISK-27273 #close

Change-Id: I49934e093290d308506ab8d45a40ef705c5ae4f5
---
M apps/app_voicemail.c
1 file changed, 9 insertions(+), 21 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, approved
  George Joseph: Looks good to me, but someone else must approve
  ben kolodny: Looks good to me, but someone else must approve
  Friendly Automation: Approved for Submit



diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index e7e0a5c..742c9c3 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -6660,8 +6660,6 @@
 {
 #ifdef IMAP_STORAGE
 	int newmsgs, oldmsgs;
-#else
-	char urgdir[PATH_MAX];
 #endif
 	char txtfile[PATH_MAX];
 	char tmptxtfile[PATH_MAX];
@@ -7080,6 +7078,14 @@
 		}
 		res = play_record_review(chan, NULL, tmptxtfile, vmu->maxsecs, fmt, 1, vmu, &duration, &sound_duration, NULL, options->record_gain, vms, flag, msg_id, 0);
 
+		/* At this point, either we were instructed to make the message Urgent
+		   by arguments to VoiceMail or during the review process by the person
+		   leaving the message. So we update the directory where we want this
+		   message to go. */
+		if (!strcmp(flag, "Urgent")) {
+			create_dirpath(dir, sizeof(dir), vmu->context, ext, "Urgent");
+		}
+
 		if (txt) {
 			fprintf(txt, "flag=%s\n", flag);
 			if (sound_duration < vmu->minsecs) {
@@ -7160,25 +7166,7 @@
 							free_user(recip);
 						}
 					}
-#ifndef IMAP_STORAGE
-					if (!ast_strlen_zero(flag) && !strcmp(flag, "Urgent")) { /* If this is an Urgent message */
-						/* Move the message from INBOX to Urgent folder if this is urgent! */
-						char sfn[PATH_MAX];
-						char dfn[PATH_MAX];
-						int x;
-						/* It's easier just to try to make it than to check for its existence */
-						create_dirpath(urgdir, sizeof(urgdir), vmu->context, ext, "Urgent");
-						x = last_message_index(vmu, urgdir) + 1;
-						make_file(sfn, sizeof(sfn), dir, msgnum);
-						make_file(dfn, sizeof(dfn), urgdir, x);
-						ast_debug(5, "Created an Urgent message, moving file from %s to %s.\n", sfn, dfn);
-						RENAME(dir, msgnum, vmu->mailbox, vmu->context, urgdir, x, sfn, dfn);
-						/* Notification must happen for this new message in Urgent folder, not INBOX */
-						ast_copy_string(fn, dfn, sizeof(fn));
-						pbx_builtin_setvar_helper(chan, "VM_MESSAGEFILE", fn);
-						msgnum = x;
-					}
-#endif
+
 					/* Notification needs to happen after the copy, though. */
 					if (ast_fileexists(fn, NULL, NULL)) {
 #ifdef IMAP_STORAGE

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

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: I49934e093290d308506ab8d45a40ef705c5ae4f5
Gerrit-Change-Number: 14807
Gerrit-PatchSet: 2
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: ben kolodny <3232963 at gmail.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200825/c524f003/attachment-0001.html>


More information about the asterisk-code-review mailing list