From 61915c7d17d99ff7457b3a824beae65d67ca5ee3 Mon Sep 17 00:00:00 2001 From: Irina Peshinskaya Date: Mon, 11 Jun 2018 02:59:10 +0200 Subject: [PATCH] TT#33113 Apply callee_in rewrite rules to fax csc number To enable correct routing Change-Id: Ie422b13804431a4d56766a3fc150f896b817d553 --- lib/NGCP/Panel/Utils/Fax.pm | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/NGCP/Panel/Utils/Fax.pm b/lib/NGCP/Panel/Utils/Fax.pm index 22d84c13cd..adc50592dc 100644 --- a/lib/NGCP/Panel/Utils/Fax.pm +++ b/lib/NGCP/Panel/Utils/Fax.pm @@ -10,6 +10,7 @@ use TryCatch; use IPC::System::Simple qw/capture/; use Data::Dumper; use Net::Ping; +use URI::Escape qw(uri_unescape); sub send_fax { my (%args) = @_; @@ -58,6 +59,26 @@ sub send_fax { } else { $number = $sender; } + { + my ($user, $domain) = split(/\@/, $args{destination}); + $user =~ s/^sips?://; + $user = uri_unescape(NGCP::Panel::Utils::Subscriber::apply_rewrite( + c => $c, subscriber => $subscriber, number => $user, direction => 'callee_in' + )); + + if ($user) { + if($domain && $domain ne $subscriber->domain->domain) { + $user = $user . '@' . $domain; + } + $c->log->debug('number normalization: caller_in apply_rewrite result for '.$args{destination}.', billing subscriber id '.$subscriber->id.': user='.$user.'.'); + + $args{destination} = $user; + + } else { + $c->log->debug('number normalization: caller_in apply_rewrite result is empty for '.$args{destination}.', billing subscriber id '.$subscriber->id.'.'); + } + } + $sendfax_args{caller} = $number; $sendfax_args{callee} = $args{destination}; @@ -210,11 +231,11 @@ sub process_fax_journal_item { #try harder: my $callee = $resource->{callee}; if (my $rt_callee = NGCP::Panel::Utils::Subscriber::apply_rewrite( - c => $c, - number => $callee, - subscriber => $src_sub // $subscriber, - direction => 'callee_in' - )) { + c => $c, + number => $callee, + subscriber => $src_sub // $subscriber, + direction => 'callee_in' + )) { $callee = $rt_callee; #e164 $c->log->debug($label . ' no destination, normalized ' . $resource->{callee} . ' to ' . $callee); my $prov_dst_alias = $c->model('DB')->resultset('voip_dbaliases')->search({