<p>cmaj has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13084">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_voicemail.c: Fix check on forwarded voicemail-to-email message body<br><br>Check for forwarded messages by looking at the original mail box<br>number in the meta text file describing the individual message.<br>The previous check was not working for file system based voicemail<br>storage -- forwarded messages were being sent with the incorrect email<br>message body.<br><br>ASTERISK-28593<br>Reported-by: cmaj<br><br>Change-Id: Ife1c9ec8e7529b4d5da7f0ccf9b95cebcd5a6009<br>---<br>M apps/app_voicemail.c<br>1 file changed, 24 insertions(+), 25 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/84/13084/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c</span><br><span>index 7343bb2..3e9afb4 100644</span><br><span>--- a/apps/app_voicemail.c</span><br><span>+++ b/apps/app_voicemail.c</span><br><span>@@ -5328,24 +5328,26 @@</span><br><span>                        ast_log(AST_LOG_WARNING, "Cannot allocate the channel for variables substitution\n");</span><br><span>              }</span><br><span>    } else {</span><br><span style="color: hsl(0, 100%, 40%);">-                if (strcmp(vmu->mailbox, mailbox)) {</span><br><span style="color: hsl(0, 100%, 40%);">-                 /* Forwarded type */</span><br><span style="color: hsl(0, 100%, 40%);">-                    struct ast_config *msg_cfg;</span><br><span style="color: hsl(0, 100%, 40%);">-                     const char *v;</span><br><span style="color: hsl(0, 100%, 40%);">-                  int inttime;</span><br><span style="color: hsl(0, 100%, 40%);">-                    char fromdir[256], fromfile[256], origdate[80] = "", origcallerid[80] = "";</span><br><span style="color: hsl(0, 100%, 40%);">-                 struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE };</span><br><span style="color: hsl(0, 100%, 40%);">-                        /* Retrieve info from VM attribute file */</span><br><span style="color: hsl(0, 100%, 40%);">-                      make_dir(fromdir, sizeof(fromdir), vmu->context, vmu->mailbox, fromfolder);</span><br><span style="color: hsl(0, 100%, 40%);">-                       make_file(fromfile, sizeof(fromfile), fromdir, msgnum);</span><br><span style="color: hsl(0, 100%, 40%);">-                 if (strlen(fromfile) < sizeof(fromfile) - 5) {</span><br><span style="color: hsl(0, 100%, 40%);">-                               strcat(fromfile, ".txt");</span><br><span style="color: hsl(120, 100%, 40%);">+           /* Possibly a Forwarded type - need to check the message meta text. */</span><br><span style="color: hsl(120, 100%, 40%);">+                struct ast_config *msg_cfg;</span><br><span style="color: hsl(120, 100%, 40%);">+           const char *v;</span><br><span style="color: hsl(120, 100%, 40%);">+                int inttime;</span><br><span style="color: hsl(120, 100%, 40%);">+          char fromdir[256], fromfile[256], origdate[80] = "", origcallerid[80] = "", origmailbox[80] = "";</span><br><span style="color: hsl(120, 100%, 40%);">+               struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE };</span><br><span style="color: hsl(120, 100%, 40%);">+              /* Retrieve info from VM attribute file */</span><br><span style="color: hsl(120, 100%, 40%);">+            make_dir(fromdir, sizeof(fromdir), vmu->context, vmu->mailbox, fromfolder);</span><br><span style="color: hsl(120, 100%, 40%);">+             make_file(fromfile, sizeof(fromfile), fromdir, msgnum);</span><br><span style="color: hsl(120, 100%, 40%);">+               if (strlen(fromfile) < sizeof(fromfile) - 5) {</span><br><span style="color: hsl(120, 100%, 40%);">+                     strcat(fromfile, ".txt");</span><br><span style="color: hsl(120, 100%, 40%);">+           }</span><br><span style="color: hsl(120, 100%, 40%);">+             if ((msg_cfg = ast_config_load(fromfile, config_flags)) && valid_config(msg_cfg)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                   if ((v = ast_variable_retrieve(msg_cfg, "message", "callerid"))) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                ast_copy_string(origcallerid, v, sizeof(origcallerid));</span><br><span>                      }</span><br><span style="color: hsl(0, 100%, 40%);">-                       if ((msg_cfg = ast_config_load(fromfile, config_flags)) && valid_config(msg_cfg)) {</span><br><span style="color: hsl(0, 100%, 40%);">-                             if ((v = ast_variable_retrieve(msg_cfg, "message", "callerid"))) {</span><br><span style="color: hsl(0, 100%, 40%);">-                                  ast_copy_string(origcallerid, v, sizeof(origcallerid));</span><br><span style="color: hsl(0, 100%, 40%);">-                         }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(120, 100%, 40%);">+                     if ((v = ast_variable_retrieve(msg_cfg, "message", "origmailbox"))) {</span><br><span style="color: hsl(120, 100%, 40%);">+                             ast_copy_string(origmailbox, v, sizeof(origmailbox));</span><br><span style="color: hsl(120, 100%, 40%);">+                 }</span><br><span style="color: hsl(120, 100%, 40%);">+                     if (strcmp(origmailbox, mailbox)) {</span><br><span>                          /* You might be tempted to do origdate, except that a) it's in the wrong</span><br><span>                                  * format, and b) it's missing for IMAP recordings. */</span><br><span>                           if ((v = ast_variable_retrieve(msg_cfg, "message", "origtime")) && sscanf(v, "%30d", &inttime) == 1) {</span><br><span>@@ -5362,15 +5364,12 @@</span><br><span>                                   date, origcallerid, origdate);</span><br><span>                               ast_config_destroy(msg_cfg);</span><br><span>                         } else {</span><br><span style="color: hsl(0, 100%, 40%);">-                                goto plain_message;</span><br><span style="color: hsl(120, 100%, 40%);">+                           fprintf(p, "Dear %s:" ENDL ENDL "\tJust wanted to let you know you were just left a "</span><br><span style="color: hsl(120, 100%, 40%);">+                                     "%s long message (number %d)" ENDL "in mailbox %s from %s, on %s so you might" ENDL</span><br><span style="color: hsl(120, 100%, 40%);">+                                       "want to check it when you get a chance.  Thanks!" ENDL ENDL "\t\t\t\t--Asterisk"</span><br><span style="color: hsl(120, 100%, 40%);">+                                 ENDL ENDL, vmu->fullname, dur, msgnum + 1, mailbox,</span><br><span style="color: hsl(120, 100%, 40%);">+                                        (cidname ? cidname : (cidnum ? cidnum : "an unknown caller")), date);</span><br><span>                      }</span><br><span style="color: hsl(0, 100%, 40%);">-               } else {</span><br><span style="color: hsl(0, 100%, 40%);">-plain_message:</span><br><span style="color: hsl(0, 100%, 40%);">-                  fprintf(p, "Dear %s:" ENDL ENDL "\tJust wanted to let you know you were just left a "</span><br><span style="color: hsl(0, 100%, 40%);">-                               "%s long message (number %d)" ENDL "in mailbox %s from %s, on %s so you might" ENDL</span><br><span style="color: hsl(0, 100%, 40%);">-                         "want to check it when you get a chance.  Thanks!" ENDL ENDL "\t\t\t\t--Asterisk"</span><br><span style="color: hsl(0, 100%, 40%);">-                           ENDL ENDL, vmu->fullname, dur, msgnum + 1, mailbox,</span><br><span style="color: hsl(0, 100%, 40%);">-                          (cidname ? cidname : (cidnum ? cidnum : "an unknown caller")), date);</span><br><span>              }</span><br><span>    }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13084">change 13084</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/13084"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ife1c9ec8e7529b4d5da7f0ccf9b95cebcd5a6009 </div>
<div style="display:none"> Gerrit-Change-Number: 13084 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: cmaj <chris@penguinpbx.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>