MT#63090 /api/calllists add phonebook entries support

* new fields:
  own_phonebook_name (matched name in the phonebook by the number)
  own_phonebook_id (id of the matched phonebook entry)
  other_phonebook_name (matched name in the phonebook by the number)
  other_phonebook_id (id of the matched phonebook entry)
* matching happens in the v_subscriber_phonebook (so all inherited
  entries are returned)

Change-Id: I5a0c825a8de28cd9fb11cf5e74b3941b5ba3b01c
mr14.0
Kirill Solomko 8 months ago
parent 19c7da53c9
commit c5e6d15800

@ -67,6 +67,43 @@ has_field 'status' => (
title => ['The status of the call, one of ok, busy, noanswer, cancel, offline, timeout, other.']
},
);
has_field 'own_phonebook_name' => (
type => 'Text',
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['Phonebook name associated to the own number'],
},
);
has_field 'own_phonebook_id' => (
type => 'PosInteger',
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['Phonebook entry id associated to the own number'],
},
);
has_field 'other_phonebook_name' => (
type => 'Text',
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['Phonebook name associated to the other number'],
},
);
has_field 'other_phonebook_id' => (
type => 'PosInteger',
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['Phonebook entry id associated to the other number'],
},
);
has_field 'rating_status' => (
type => 'Select',
required => 1,

@ -40,6 +40,10 @@ use constant ENABLE_SUPPRESSIONS => 1; #setting to 0 totally disables call list
# * status
# * rating_status
# * type
# * own_phonebook_name
# * own_phonebook_id
# * other_phonebook_name
# * other_phonebook_id
sub process_cdr_item {
my ($c, $item, $owner, $params) = @_;
@ -287,6 +291,79 @@ sub process_cdr_item {
}
}
$resource->{own_phonebook_id} = undef;
$resource->{own_phonebook_name} = undef;
my ($own_phonebook_entries, $other_phonebook_entries);
if ($resource->{direction} eq "out") {
$own_phonebook_entries =
$c->model('DB')->resultset('v_subscriber_phonebook')->search({
number => {
'-in' => [
$resource->{own_cli},
$item->source_user,
$item->source_cli,
],
},
subscriber_id => $billing_src_sub->id,
},{
rows => 1,
});
$other_phonebook_entries =
$c->model('DB')->resultset('v_subscriber_phonebook')->search({
number => {
'-in' => [
$resource->{other_cli},
$item->destination_user,
$item->destination_user_in,
$item->destination_user_dialed,
],
},
subscriber_id => $billing_src_sub->id,
},{
rows => 1
});
} else {
$own_phonebook_entries =
$c->model('DB')->resultset('v_subscriber_phonebook')->search({
number => {
'-in' => [
$resource->{own_cli},
$item->destination_user,
$item->destination_user_in,
$item->destination_user_dialed,
],
},
subscriber_id => $billing_dst_sub->id,
},{
rows => 1
});
$other_phonebook_entries =
$c->model('DB')->resultset('v_subscriber_phonebook')->search({
number => {
'-in' => [
$resource->{other_cli},
$item->source_user,
$item->source_cli,
],
},
subscriber_id => $billing_dst_sub->id,
},{
rows => 1
});
}
if ($own_phonebook_entries->first) {
$resource->{own_phonebook_id} = $own_phonebook_entries->first->id;
$resource->{own_phonebook_name} = $own_phonebook_entries->first->name;
}
if ($other_phonebook_entries->first) {
$resource->{other_phonebook_id} = $other_phonebook_entries->first->id;
$resource->{other_phonebook_name} = $other_phonebook_entries->first->name;
}
my @own_details = ();
if ($own_suppression) {
$c->log->debug('own suppression: id = ' . $own_suppression->id . ' direction = ' . $own_suppression->direction .

Loading…
Cancel
Save