[Asterisk-code-review] app_voicemail: Fix missing email in msg_create_from_file. (asterisk[master])

N A asteriskteam at digium.com
Thu Nov 3 15:30:20 CDT 2022


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


Change subject: app_voicemail: Fix missing email in msg_create_from_file.
......................................................................

app_voicemail: Fix missing email in msg_create_from_file.

msg_create_from_file currently does not dispatch emails,
which means that applications using this function, such
as MixMonitor, will not trigger notifications to users
(only AMI events are sent our currently). This is inconsistent
with other ways users can receive voicemail.

This is fixed by attempting to send an email and falling back
to just the notifications as done previously if we fail.

ASTERISK-30283 #close

Change-Id: I597cbb9cf971a18d8776172b26ab187dc096a5c7
---
M apps/app_voicemail.c
1 file changed, 40 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/68/19468/1

diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 510e15d..10e6f9e 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -6418,6 +6418,11 @@
 	 * 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
 	 * time to create the voicemail database entry. */
 	if (ast_fileexists(destination, NULL, NULL) > 0) {
+		struct ast_channel *chan;
+		char fmt[80];
+		char clid[80];
+		char cidnum[80], cidname[80];
+
 		if (ast_check_realtime("voicemail_data")) {
 			get_date(date, sizeof(date));
 			ast_store_realtime("voicemail_data",
@@ -6437,7 +6442,21 @@
 		}
 
 		STORE(dir, recipient->mailbox, recipient->context, msgnum, NULL, recipient, fmt, 0, vms, "", msg_id);
-		notify_new_state(recipient);
+
+		/* Send an email if possible, fall back to just notifications if not. */
+		ast_copy_string(fmt, recdata->recording_ext, sizeof(fmt));
+		ast_copy_string(clid, recdata->call_callerid, sizeof(clid));
+		ast_callerid_split(clid, cidname, sizeof(cidname), cidnum, sizeof(cidnum));
+
+		/* recdata->call_callerchan itself no longer exists, so we can't use the real channel. Use a dummy one. */
+		chan = ast_dummy_channel_alloc();
+		if (chan) {
+			notify_new_message(chan, recipient, NULL, msgnum, duration, fmt, cidnum, cidname, "");
+			ast_channel_unref(chan);
+		} else {
+			ast_log(LOG_WARNING, "Failed to allocate dummy channel, email will not be sent\n");
+			notify_new_state(recipient);
+		}
 	}
 
 	free_user(recipient);

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I597cbb9cf971a18d8776172b26ab187dc096a5c7
Gerrit-Change-Number: 19468
Gerrit-PatchSet: 1
Gerrit-Owner: N A <asterisk at phreaknet.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221103/08ffdce9/attachment.html>


More information about the asterisk-code-review mailing list