[Asterisk-code-review] app_mixmonitor: Add option to use real Caller ID for voicemail. (asterisk[master])

N A asteriskteam at digium.com
Fri Nov 4 06:05:47 CDT 2022


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


Change subject: app_mixmonitor: Add option to use real Caller ID for voicemail.
......................................................................

app_mixmonitor: Add option to use real Caller ID for voicemail.

MixMonitor currently uses the Connected Line as the Caller ID
for voicemails. This is due to the implementation being written
this way for use with Digium phones. However, in general this
is not correct for generic usage in the dialplan, and people
may need the real Caller ID instead. This adds an option to do that.

ASTERISK-30286 #close

Change-Id: I3d0ce76dfe75e2a614e0f709ab27acbd2478267c
---
M apps/app_mixmonitor.c
A doc/CHANGES-staging/app_mixmonitor_clid.txt
2 files changed, 57 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/72/19472/1

diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c
index a0eb1db..464bef0 100644
--- a/apps/app_mixmonitor.c
+++ b/apps/app_mixmonitor.c
@@ -90,6 +90,11 @@
 						<para>Play a periodic beep while this call is being recorded.</para>
 						<argument name="interval"><para>Interval, in seconds. Default is 15.</para></argument>
 					</option>
+					<option name="c">
+						<para>Use the real Caller ID for the voicemail Caller ID.</para>
+						<para>By default, the Connected Line is used. If you want the channel caller's
+						real number, you may need to specify this option.</para>
+					</option>
 					<option name="v">
 						<para>Adjust the <emphasis>heard</emphasis> volume by a factor of <replaceable>x</replaceable>
 						(range <literal>-4</literal> to <literal>4</literal>)</para>
@@ -137,7 +142,7 @@
 						<para>Create a copy of the recording as a voicemail in the indicated <emphasis>mailbox</emphasis>(es)
 						separated by commas eg. m(1111 at default,2222 at default,...).  Folders can be optionally specified using
 						the syntax: mailbox at context/folder</para>
-					</option>
+						</option>
 				</optionlist>
 			</parameter>
 			<parameter name="command">
@@ -407,6 +412,7 @@
 	MUXFLAG_BEEP_STOP = (1 << 13),
 	MUXFLAG_DEPRECATED_RWSYNC = (1 << 14),
 	MUXFLAG_NO_RWSYNC = (1 << 15),
+	MUXFLAG_REAL_CALLERID = (1 << 16),
 };
 
 enum mixmonitor_args {
@@ -427,6 +433,7 @@
 	AST_APP_OPTION('a', MUXFLAG_APPEND),
 	AST_APP_OPTION('b', MUXFLAG_BRIDGED),
 	AST_APP_OPTION_ARG('B', MUXFLAG_BEEP, OPT_ARG_BEEP_INTERVAL),
+	AST_APP_OPTION('c', MUXFLAG_REAL_CALLERID),
 	AST_APP_OPTION('p', MUXFLAG_BEEP_START),
 	AST_APP_OPTION('P', MUXFLAG_BEEP_STOP),
 	AST_APP_OPTION_ARG('v', MUXFLAG_READVOLUME, OPT_ARG_READVOLUME),
@@ -1015,20 +1022,37 @@
 
 	if (!ast_strlen_zero(recipients)) {
 		char callerid[256];
-		struct ast_party_connected_line *connected;
 
 		ast_channel_lock(chan);
 
-		/* We use the connected line of the invoking channel for caller ID. */
+		/* We use the connected line of the invoking channel for caller ID,
+		 * unless we've been told to use the Caller ID.
+		 * The initial use for this relied on Connected Line to get the
+		 * actual number for recording with Digium phones,
+		 * but in generic use the Caller ID is likely what people want.
+		 */
 
-		connected = ast_channel_connected(chan);
-		ast_debug(3, "Connected Line CID = %d - %s : %d - %s\n", connected->id.name.valid,
-			connected->id.name.str, connected->id.number.valid,
-			connected->id.number.str);
-		ast_callerid_merge(callerid, sizeof(callerid),
-			S_COR(connected->id.name.valid, connected->id.name.str, NULL),
-			S_COR(connected->id.number.valid, connected->id.number.str, NULL),
-			"Unknown");
+		if (ast_test_flag(mixmonitor, MUXFLAG_REAL_CALLERID)) {
+			struct ast_party_caller *caller;
+			caller = ast_channel_caller(chan);
+			ast_debug(3, "Caller ID = %d - %s : %d - %s\n", caller->id.name.valid,
+				caller->id.name.str, caller->id.number.valid,
+				caller->id.number.str);
+			ast_callerid_merge(callerid, sizeof(callerid),
+				S_COR(caller->id.name.valid, caller->id.name.str, NULL),
+				S_COR(caller->id.number.valid, caller->id.number.str, NULL),
+				"Unknown");
+		} else {
+			struct ast_party_connected_line *connected;
+			connected = ast_channel_connected(chan);
+			ast_debug(3, "Connected Line CID = %d - %s : %d - %s\n", connected->id.name.valid,
+				connected->id.name.str, connected->id.number.valid,
+				connected->id.number.str);
+			ast_callerid_merge(callerid, sizeof(callerid),
+				S_COR(connected->id.name.valid, connected->id.name.str, NULL),
+				S_COR(connected->id.number.valid, connected->id.number.str, NULL),
+				"Unknown");
+		}
 
 		ast_string_field_set(mixmonitor, call_context, ast_channel_context(chan));
 		ast_string_field_set(mixmonitor, call_macrocontext, ast_channel_macrocontext(chan));
diff --git a/doc/CHANGES-staging/app_mixmonitor_clid.txt b/doc/CHANGES-staging/app_mixmonitor_clid.txt
new file mode 100644
index 0000000..a8331ec
--- /dev/null
+++ b/doc/CHANGES-staging/app_mixmonitor_clid.txt
@@ -0,0 +1,5 @@
+Subject: app_mixmonitor
+
+Adds the c option to use the real Caller ID on
+the channel in voicemail recordings as opposed
+to the Connected Line.

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I3d0ce76dfe75e2a614e0f709ab27acbd2478267c
Gerrit-Change-Number: 19472
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/20221104/2251b21a/attachment.html>


More information about the asterisk-code-review mailing list