|
|
|
@ -211,8 +211,7 @@ sub get_list{
|
|
|
|
|
#TODO: move to config and return to the SUPER (Entities) again
|
|
|
|
|
#So: if config->{methtod}->{required_params} eq '' owner
|
|
|
|
|
#and for other types of possible required parameters or predefined parameters groups
|
|
|
|
|
my $schema = $c->model('DB');
|
|
|
|
|
my $owner = NGCP::Panel::Utils::API::Calllist::get_owner_data($self, $c, $schema);
|
|
|
|
|
my $owner = $self->get_owner_cached($c);
|
|
|
|
|
unless (defined $owner) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -241,8 +240,15 @@ sub get_item_id{
|
|
|
|
|
$type = $item->type;
|
|
|
|
|
}
|
|
|
|
|
if(('HASH' eq ref $params) && 'hal_links_href' eq $params->{purpose}){
|
|
|
|
|
return $id.'?type='.$type;
|
|
|
|
|
|
|
|
|
|
my $owner = $self->get_owner_cached( $c);
|
|
|
|
|
return unless $owner;
|
|
|
|
|
return $id.'?type='.$type
|
|
|
|
|
.($owner->{subscriber}
|
|
|
|
|
? '&subscriber_id='.$owner->{subscriber}->id
|
|
|
|
|
: ( $owner->{customer} )
|
|
|
|
|
? '&customer_id='.$owner->{customer}->id
|
|
|
|
|
: ''
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return $id ;
|
|
|
|
|
}
|
|
|
|
@ -748,20 +754,18 @@ sub process_hal_resource {
|
|
|
|
|
$c->log->debug(Dumper($item));
|
|
|
|
|
my ($item_mock_obj, $item_accessors_hash) = _get_item_object($c, $item);
|
|
|
|
|
if('call' eq $item->{type}){
|
|
|
|
|
my $cdr_subscriber_id = $c->model('DB')->resultset('voip_subscribers')->search_rs({
|
|
|
|
|
'uuid' => $item_mock_obj->source_user_id,
|
|
|
|
|
})->first->id;
|
|
|
|
|
my $cdr_customer_id = $item_mock_obj->source_account_id;
|
|
|
|
|
my $owner = NGCP::Panel::Utils::API::Calllist::get_owner_data($self, $c, $schema, { subscriber_id => $cdr_subscriber_id } );
|
|
|
|
|
if(!$owner){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
my $owner = $self->get_owner_cached($c);
|
|
|
|
|
return unless $owner;
|
|
|
|
|
$resource = NGCP::Panel::Utils::CallList::process_cdr_item(
|
|
|
|
|
$c,
|
|
|
|
|
$item_mock_obj,
|
|
|
|
|
$owner,
|
|
|
|
|
);
|
|
|
|
|
@{$resource}{qw/caller callee/} = @{$resource}{qw/own_cli other_cli/};
|
|
|
|
|
if ("out" eq $resource->{direction}) {
|
|
|
|
|
@{$resource}{qw/caller callee/} = @{$resource}{qw/own_cli other_cli/};
|
|
|
|
|
} else {
|
|
|
|
|
@{$resource}{qw/caller callee/} = @{$resource}{qw/other_cli own_cli/};
|
|
|
|
|
}
|
|
|
|
|
$resource->{type} = $item->{type};
|
|
|
|
|
my $fee;
|
|
|
|
|
if ($fee = $schema->resultset('billing_fees_history')->search_rs({
|
|
|
|
@ -822,6 +826,19 @@ sub process_hal_resource {
|
|
|
|
|
return $resource;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub get_owner_cached{
|
|
|
|
|
my ($self, $c) = @_;
|
|
|
|
|
my $schema = $c->model('DB');
|
|
|
|
|
if ( ! $c->stash->{owner} ) {
|
|
|
|
|
my $source;
|
|
|
|
|
if ($c->req->params->{customer_id} or $c->req->params->{subscriber_id}) {
|
|
|
|
|
$source = $c->req->params;
|
|
|
|
|
}
|
|
|
|
|
$c->stash->{owner} = NGCP::Panel::Utils::API::Calllist::get_owner_data($self, $c, $schema, $source);
|
|
|
|
|
}
|
|
|
|
|
return $c->stash->{owner};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub _get_fields_names{
|
|
|
|
|
my ($fields, $fields_tied) = @_;
|
|
|
|
|
return { map { $_ => $fields_tied->Indices($_) ? _get_alias($fields_tied->Indices($_) + 1) : $_; } (keys %$fields, 'id','type','timestamp') };
|
|
|
|
|