<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19672">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_voicemail: Fix missing email in msg_create_from_file.<br><br>msg_create_from_file currently does not dispatch emails,<br>which means that applications using this function, such<br>as MixMonitor, will not trigger notifications to users<br>(only AMI events are sent our currently). This is inconsistent<br>with other ways users can receive voicemail.<br><br>This is fixed by adding an option that attempts to send<br>an email and falling back to just the notifications as<br>done now if that fails. The existing behavior remains<br>the default.<br><br>ASTERISK-30283 #close<br><br>Change-Id: I597cbb9cf971a18d8776172b26ab187dc096a5c7<br>---<br>M apps/app_voicemail.c<br>M configs/samples/voicemail.conf.sample<br>A doc/CHANGES-staging/app_voicemail_attachext.txt<br>3 files changed, 59 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/72/19672/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 510e15d..1aca59b 100644</span><br><span>--- a/apps/app_voicemail.c</span><br><span>+++ b/apps/app_voicemail.c</span><br><span>@@ -570,6 +570,7 @@</span><br><span> #define VM_MOVEHEARD (1 << 16) /*!< Move a "heard" message to Old after listening to it */</span><br><span> #define VM_MESSAGEWRAP (1 << 17) /*!< Wrap around from the last message to the first, and vice-versa */</span><br><span> #define VM_FWDURGAUTO (1 << 18) /*!< Autoset of Urgent flag on forwarded Urgent messages set globally */</span><br><span style="color: hsl(120, 100%, 40%);">+#define VM_EMAIL_EXT_RECS (1 << 19) /*!< Send voicemail emails when an external recording is added to a mailbox */</span><br><span> #define ERROR_LOCK_PATH -100</span><br><span> #define ERROR_MAX_MSGS -101</span><br><span> #define OPERATOR_EXIT 300</span><br><span>@@ -1258,6 +1259,8 @@</span><br><span> ast_set2_flag(vmu, ast_true(value), VM_ATTACH);</span><br><span> } else if (!strcasecmp(var, "attachfmt")) {</span><br><span> ast_copy_string(vmu->attachfmt, value, sizeof(vmu->attachfmt));</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (!strcasecmp(var, "attachextrecs")) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_set2_flag(vmu, ast_true(value), VM_EMAIL_EXT_RECS);</span><br><span> } else if (!strcasecmp(var, "serveremail")) {</span><br><span> ast_copy_string(vmu->serveremail, value, sizeof(vmu->serveremail));</span><br><span> } else if (!strcasecmp(var, "fromstring")) {</span><br><span>@@ -6418,6 +6421,12 @@</span><br><span> * to do both with one line and is also safe to use with file storage mode. Also, if we are using ODBC, now is a good</span><br><span> * time to create the voicemail database entry. */</span><br><span> if (ast_fileexists(destination, NULL, NULL) > 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_channel *chan = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ char fmt[80];</span><br><span style="color: hsl(120, 100%, 40%);">+ char clid[80];</span><br><span style="color: hsl(120, 100%, 40%);">+ char cidnum[80], cidname[80];</span><br><span style="color: hsl(120, 100%, 40%);">+ int send_email;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (ast_check_realtime("voicemail_data")) {</span><br><span> get_date(date, sizeof(date));</span><br><span> ast_store_realtime("voicemail_data",</span><br><span>@@ -6437,7 +6446,27 @@</span><br><span> }</span><br><span> </span><br><span> STORE(dir, recipient->mailbox, recipient->context, msgnum, NULL, recipient, fmt, 0, vms, "", msg_id);</span><br><span style="color: hsl(0, 100%, 40%);">- notify_new_state(recipient);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ send_email = ast_test_flag(recipient, VM_EMAIL_EXT_RECS);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (send_email) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Send an email if possible, fall back to just notifications if not. */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(fmt, recdata->recording_ext, sizeof(fmt));</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(clid, recdata->call_callerid, sizeof(clid));</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_callerid_split(clid, cidname, sizeof(cidname), cidnum, sizeof(cidnum));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* recdata->call_callerchan itself no longer exists, so we can't use the real channel. Use a dummy one. */</span><br><span style="color: hsl(120, 100%, 40%);">+ chan = ast_dummy_channel_alloc();</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ if (chan) {</span><br><span style="color: hsl(120, 100%, 40%);">+ notify_new_message(chan, recipient, NULL, msgnum, duration, fmt, cidnum, cidname, "");</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_unref(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (send_email) { /* We tried and failed. */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "Failed to allocate dummy channel, email will not be sent\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ notify_new_state(recipient);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> </span><br><span> free_user(recipient);</span><br><span>diff --git a/configs/samples/voicemail.conf.sample b/configs/samples/voicemail.conf.sample</span><br><span>index 30054b5..e799cf6 100644</span><br><span>--- a/configs/samples/voicemail.conf.sample</span><br><span>+++ b/configs/samples/voicemail.conf.sample</span><br><span>@@ -262,6 +262,8 @@</span><br><span> ; option lets you customize the format sent to particular mailboxes.</span><br><span> ; Useful if Windows users want wav49, but Linux users want gsm.</span><br><span> ; [per-mailbox only]</span><br><span style="color: hsl(120, 100%, 40%);">+; attachextrecs=no ; Whether to attach recordings that are externally added to mailboxes,</span><br><span style="color: hsl(120, 100%, 40%);">+ ; such as through MixMonitor. Default is no.</span><br><span> ; saycid=yes ; Say the caller id information before the message. If not described,</span><br><span> ; or set to no, it will be in the envelope. When enabled, if a recorded file</span><br><span> ; with the same name as the caller id exists in</span><br><span>diff --git a/doc/CHANGES-staging/app_voicemail_attachext.txt b/doc/CHANGES-staging/app_voicemail_attachext.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..c56f04a</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/app_voicemail_attachext.txt</span><br><span>@@ -0,0 +1,5 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: app_voicemail</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The voicemail user option attachextrecs can</span><br><span style="color: hsl(120, 100%, 40%);">+now be set to control whether external recordings</span><br><span style="color: hsl(120, 100%, 40%);">+trigger voicemail email notifications.</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19672">change 19672</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/+/19672"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: I597cbb9cf971a18d8776172b26ab187dc096a5c7 </div>
<div style="display:none"> Gerrit-Change-Number: 19672 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: N A <asterisk@phreaknet.org> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>