TT#12659 better representation for anonymous calls. add "clir" field

- mask (anonymise) the caller if source_clir is enabled and the auth
      role is non-admin, and the call is not inside the same customer
    - if source_cli is "anonymous" try to use source_user@source_domain
      as the caller and in case if the "domain part" is used check and
      mask it if the auth user is non-admin

Change-Id: I835679ed7a2a0c070542fbd9a625fed7ffe2d71f
changes/21/12621/6
Kirill Solomko 9 years ago
parent 0586bf053c
commit afa5a6072f

@ -2328,6 +2328,7 @@ sub calllist_master :Chained('base') :PathPart('calls') :CaptureArgs(0) {
{ name => "direction", search => 1, literal_sql => 'if(source_user_id = "'.$c->stash->{subscriber}->uuid.'", "outgoing", "incoming")' },
{ name => "source_user", search => 1, title => $c->loc('Caller') },
{ name => "destination_user", search => 1, title => $c->loc('Callee') },
{ name => "clir", search => 1, title => $c->loc('CLIR') },
{ name => "source_customer_billing_zones_history.detail", search => 1, title => $c->loc('Billing zone') },
{ name => "call_status", search => 1, title => $c->loc('Status') },
{ name => "start_time", search_from_epoch => 1, search_to_epoch => 1, title => $c->loc('Start Time') },
@ -3533,6 +3534,7 @@ sub _process_calls_rows {
$data{source_user} = uri_unescape($resource->{other_cli});
$data{destination_user} = uri_unescape($resource->{own_cli});
}
$data{clir} = $resource->{clir};
$data{duration} = (defined $result->duration ? sprintf("%.2f s", $result->duration) : "");
$data{duration} = (defined $result->duration ? NGCP::Panel::Utils::DateTime::sec_to_hms($c,$result->duration,3) : "");
$data{total_customer_cost} = (defined $result->get_column('total_customer_cost') ? sprintf("%.2f", $result->get_column('total_customer_cost') / 100.0) : "");

@ -41,6 +41,15 @@ has_field 'other_cli' => (
},
);
has_field 'clir' => (
type => 'Text',
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['CLIR indicator for the call'],
},
);
has_field 'status' => (
type => 'Select',
required => 1,

@ -21,6 +21,7 @@ use NGCP::Panel::Utils::Subscriber;
# * intra_customer
# * other_cli
# * own_cli
# * clir
# * start_time
# * status
# * rating_status
@ -54,6 +55,15 @@ sub process_cdr_item {
$resource->{direction} = "out";
}
my $anonymize = $c->user->roles ne "admin" && !$intra && $item->source_clir;
# try to use source_cli first and if it is "anonymous" fall-back to
# source_user@source_domain + mask the domain for non-admins
my $source_cli = $item->source_cli !~ /anonymous/i
? $item->source_cli
: $item->source_user . '@' . $item->source_domain;
$source_cli = $anonymize ? 'anonymous@anonymous.invalid' : $source_cli;
$resource->{clir} = $item->source_clir;
my ($src_sub, $dst_sub);
my $billing_src_sub = $item->source_subscriber;
my $billing_dst_sub = $item->destination_subscriber;
@ -73,15 +83,15 @@ sub process_cdr_item {
# for termianted subscribers if there is an alias field (e.g. gpp0), use this
} elsif($item->source_account_id && $params->{'intra_alias_field'}) {
my $alias = $item->get_column('source_'.$params->{'intra_alias_field'});
$resource->{own_cli} = $alias // $item->source_cli;
$resource->{own_cli} = $alias // $source_cli;
$own_normalize = 0;
# if there is an alias field (e.g. gpp0), use this
} elsif($item->source_account_id && $params->{'alias_field'}) {
my $alias = $item->get_column('source_'.$params->{'alias_field'});
$resource->{own_cli} = $alias // $item->source_cli;
$resource->{own_cli} = $alias // $source_cli;
$own_normalize = 1;
} else {
$resource->{own_cli} = $item->source_cli;
$resource->{own_cli} = $source_cli;
$own_normalize = 1;
}
$own_domain = $item->source_domain;
@ -151,15 +161,15 @@ sub process_cdr_item {
# for termianted subscribers if there is an alias field (e.g. gpp0), use this
} elsif($intra && $item->source_account_id && $params->{'intra_alias_field'}) {
my $alias = $item->get_column('source_'.$params->{'intra_alias_field'});
$resource->{other_cli} = $alias // $item->source_cli;
$resource->{other_cli} = $alias // $source_cli;
$other_normalize = 0;
# if there is an alias field (e.g. gpp0), use this
} elsif($item->source_account_id && $params->{'alias_field'}) {
my $alias = $item->get_column('source_'.$params->{'alias_field'});
$resource->{other_cli} = $alias // $item->source_cli;
$resource->{other_cli} = $alias // $source_cli;
$other_normalize = 1;
} else {
$resource->{other_cli} = $item->source_cli;
$resource->{other_cli} = $source_cli;
$other_normalize = 1;
}
$other_domain = $item->source_domain;
@ -184,7 +194,7 @@ sub process_cdr_item {
? $billing_dst_sub
: $billing_src_sub;
if($resource->{own_cli} !~ /^\d+$/) {
if($resource->{own_cli} !~ /(^\d+$|[\@])/) {
$resource->{own_cli} .= '@'.$own_domain;
} elsif($own_normalize) {
if (my $normalized_cli = NGCP::Panel::Utils::Subscriber::apply_rewrite(
@ -196,7 +206,7 @@ sub process_cdr_item {
if($resource->{direction} eq "in" && $item->source_clir && $intra == 0) {
$resource->{other_cli} = undef;
} elsif(!$other_skip_domain && $resource->{other_cli} !~ /^\d+$/) {
} elsif(!$other_skip_domain && $resource->{other_cli} !~ /(^\d+$|[\@])/) {
$resource->{other_cli} .= '@'.$other_domain;
} elsif($other_normalize) {
if (my $normalized_cli = NGCP::Panel::Utils::Subscriber::apply_rewrite(

Loading…
Cancel
Save