[Asterisk-code-review] app_voicemail.c: Fix check on forwarded voicemail-to-email message body (...asterisk[master])

cmaj asteriskteam at digium.com
Fri Oct 18 14:38:29 CDT 2019


cmaj has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13084


Change subject: app_voicemail.c: Fix check on forwarded voicemail-to-email message body
......................................................................

app_voicemail.c: Fix check on forwarded voicemail-to-email message body

Check for forwarded messages by looking at the original mail box
number in the meta text file describing the individual message.
The previous check was not working for file system based voicemail
storage -- forwarded messages were being sent with the incorrect email
message body.

ASTERISK-28593
Reported-by: cmaj

Change-Id: Ife1c9ec8e7529b4d5da7f0ccf9b95cebcd5a6009
---
M apps/app_voicemail.c
1 file changed, 24 insertions(+), 25 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/84/13084/1

diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 7343bb2..3e9afb4 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -5328,24 +5328,26 @@
 			ast_log(AST_LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
 		}
 	} else {
-		if (strcmp(vmu->mailbox, mailbox)) {
-			/* Forwarded type */
-			struct ast_config *msg_cfg;
-			const char *v;
-			int inttime;
-			char fromdir[256], fromfile[256], origdate[80] = "", origcallerid[80] = "";
-			struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE };
-			/* Retrieve info from VM attribute file */
-			make_dir(fromdir, sizeof(fromdir), vmu->context, vmu->mailbox, fromfolder);
-			make_file(fromfile, sizeof(fromfile), fromdir, msgnum);
-			if (strlen(fromfile) < sizeof(fromfile) - 5) {
-				strcat(fromfile, ".txt");
+		/* Possibly a Forwarded type - need to check the message meta text. */
+		struct ast_config *msg_cfg;
+		const char *v;
+		int inttime;
+		char fromdir[256], fromfile[256], origdate[80] = "", origcallerid[80] = "", origmailbox[80] = "";
+		struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE };
+		/* Retrieve info from VM attribute file */
+		make_dir(fromdir, sizeof(fromdir), vmu->context, vmu->mailbox, fromfolder);
+		make_file(fromfile, sizeof(fromfile), fromdir, msgnum);
+		if (strlen(fromfile) < sizeof(fromfile) - 5) {
+			strcat(fromfile, ".txt");
+		}
+		if ((msg_cfg = ast_config_load(fromfile, config_flags)) && valid_config(msg_cfg)) {
+			if ((v = ast_variable_retrieve(msg_cfg, "message", "callerid"))) {
+				ast_copy_string(origcallerid, v, sizeof(origcallerid));
 			}
-			if ((msg_cfg = ast_config_load(fromfile, config_flags)) && valid_config(msg_cfg)) {
-				if ((v = ast_variable_retrieve(msg_cfg, "message", "callerid"))) {
-					ast_copy_string(origcallerid, v, sizeof(origcallerid));
-				}
-
+			if ((v = ast_variable_retrieve(msg_cfg, "message", "origmailbox"))) {
+				ast_copy_string(origmailbox, v, sizeof(origmailbox));
+			}
+			if (strcmp(origmailbox, mailbox)) {
 				/* You might be tempted to do origdate, except that a) it's in the wrong
 				 * format, and b) it's missing for IMAP recordings. */
 				if ((v = ast_variable_retrieve(msg_cfg, "message", "origtime")) && sscanf(v, "%30d", &inttime) == 1) {
@@ -5362,15 +5364,12 @@
 					date, origcallerid, origdate);
 				ast_config_destroy(msg_cfg);
 			} else {
-				goto plain_message;
+				fprintf(p, "Dear %s:" ENDL ENDL "\tJust wanted to let you know you were just left a "
+					"%s long message (number %d)" ENDL "in mailbox %s from %s, on %s so you might" ENDL
+					"want to check it when you get a chance.  Thanks!" ENDL ENDL "\t\t\t\t--Asterisk"
+					ENDL ENDL, vmu->fullname, dur, msgnum + 1, mailbox,
+					(cidname ? cidname : (cidnum ? cidnum : "an unknown caller")), date);
 			}
-		} else {
-plain_message:
-			fprintf(p, "Dear %s:" ENDL ENDL "\tJust wanted to let you know you were just left a "
-				"%s long message (number %d)" ENDL "in mailbox %s from %s, on %s so you might" ENDL
-				"want to check it when you get a chance.  Thanks!" ENDL ENDL "\t\t\t\t--Asterisk"
-				ENDL ENDL, vmu->fullname, dur, msgnum + 1, mailbox,
-				(cidname ? cidname : (cidnum ? cidnum : "an unknown caller")), date);
 		}
 	}
 

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ife1c9ec8e7529b4d5da7f0ccf9b95cebcd5a6009
Gerrit-Change-Number: 13084
Gerrit-PatchSet: 1
Gerrit-Owner: cmaj <chris at penguinpbx.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20191018/95ab48b4/attachment-0001.html>


More information about the asterisk-code-review mailing list