From 85b58a48ad608c9f086c7da26b53901b9e208bc1 Mon Sep 17 00:00:00 2001 From: mattf Date: Mon, 15 Mar 2021 15:27:02 +0000 Subject: [PATCH] Populate the CIDname in live_sip_channels/live_channels tables, Issue #1255 git-svn-id: svn://192.168.202.10@3380 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/bin/AST_update_AMI2.pl | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/agc_2-X/trunk/bin/AST_update_AMI2.pl b/agc_2-X/trunk/bin/AST_update_AMI2.pl index 17242c13..19f844ea 100644 --- a/agc_2-X/trunk/bin/AST_update_AMI2.pl +++ b/agc_2-X/trunk/bin/AST_update_AMI2.pl @@ -5,7 +5,7 @@ # This script uses the Asterisk Manager interface to update the live_channels # tables and verify the parked_channels table in the asterisk MySQL database # -# Copyright (C) 2020 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2021 Matt Florell LICENSE: AGPLv2 # # CHANGES # 170915-2110 - Initial version for Asterisk 13, based upon AST_update.pl @@ -16,6 +16,7 @@ # 190102-1509 - More fixes for RINGAGENT Calls # 190121-1505 - Added RA_USER_PHONE On-Hook CID to solve last RINGAGENT issues # 201119-2119 - Fix for time logging inserts/updates to database +# 210315-1045 - Populate the CIDname in live_sip_channels/live_channels tables, Issue #1255 # # constants @@ -772,6 +773,10 @@ sub process_channels $extension =~ s/-\S+$//gi; # remove everything after a - $extension =~ s/\|.*//gi; # remove everything after the | $extension =~ s/,.*//gi; # remove everything after the , + $CIDnameSQL = $channel_ref->{'CallerIDName'}; + $CIDnameSQL =~ s/'|"|;//gi; # remove quotes and semi-colon + if (length($CIDnameSQL) > 30) + {$CIDnameSQL =~ substr($CIDnameSQL,0,30);} # make sure the channel is a channel type we care about if ( $channel_ref->{'Channel'} =~ /^IAX2|^SIP|^Local|^DAHDI/) @@ -880,7 +885,7 @@ sub process_channels { # Add this channel to the client insert if ( $client_insert_count > 0 ) { $client_insert_sql .= ", \n\t" } - $client_insert_sql .= "('$channel_ref->{'Channel'}','$server_ip','$extension','$channel_ref->{'ApplicationData'}')"; + $client_insert_sql .= "('$channel_ref->{'Channel'}','$server_ip','$extension','$CIDnameSQL','$channel_ref->{'ApplicationData'}')"; $client_insert_count++; } } @@ -909,7 +914,7 @@ sub process_channels { # Add this channel to the trunk insert if ( $trunk_insert_count > 0 ) { $trunk_insert_sql .= ", \n\t"; } - $trunk_insert_sql .= "('$channel_ref->{'Channel'}','$server_ip','$extension','$channel_ref->{'ApplicationData'}')"; + $trunk_insert_sql .= "('$channel_ref->{'Channel'}','$server_ip','$extension','$CIDnameSQL','$channel_ref->{'ApplicationData'}')"; $trunk_insert_count++; } } @@ -928,7 +933,7 @@ sub process_channels if ( $client_insert_count > 0 ) { # insert all the new clients - my $stmtA = "INSERT INTO live_sip_channels (channel,server_ip,extension,channel_data) values \n\t" . $client_insert_sql; + my $stmtA = "INSERT INTO live_sip_channels (channel,server_ip,extension,channel_group,channel_data) values \n\t" . $client_insert_sql; if ($DB) { print STDERR "$stmtA\n"; } $stmtA =~ s/\n|\t//gi; $dbhA->do($stmtA); @@ -938,7 +943,7 @@ sub process_channels if ( $trunk_insert_count > 0 ) { # insert all the new trunks - my $stmtA = "INSERT INTO live_channels (channel,server_ip,extension,channel_data) values \n\t" . $trunk_insert_sql; + my $stmtA = "INSERT INTO live_channels (channel,server_ip,extension,channel_group,channel_data) values \n\t" . $trunk_insert_sql; if ($DB) { print STDERR "$stmtA\n"; } $stmtA =~ s/\n|\t//gi; $dbhA->do($stmtA);