From 7853ae16fb6918fca999e47edfeb8e3957a14103 Mon Sep 17 00:00:00 2001 From: Marco Capetta Date: Tue, 20 Jun 2023 17:56:40 +0200 Subject: [PATCH] MT#57668 Add support for implicit reseller_id on phonebookentries api A reseller was not able to edit a phonebook entry unless it specified the reseller_id. This should not be required since the reseller could not know it. Change-Id: I347c676e291659e9a8b2a97632531dc7b06e055a --- lib/NGCP/Panel/Role/API/PhonebookEntries.pm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/NGCP/Panel/Role/API/PhonebookEntries.pm b/lib/NGCP/Panel/Role/API/PhonebookEntries.pm index 88879fda46..de6a4b8008 100644 --- a/lib/NGCP/Panel/Role/API/PhonebookEntries.pm +++ b/lib/NGCP/Panel/Role/API/PhonebookEntries.pm @@ -89,7 +89,7 @@ sub check_owner_params { $params //= $self->get_info_data($c); # Checking for implicit subscriber - no params provided. subscriber_id can be set up here. - &_check_implicit_subscriber($c, $params); + &_check_implicit_user($c, $params); my %owner_params = map { $_ => $params->{$_} } @@ -200,14 +200,16 @@ sub get_subscriber_phonebook_rs { return ($list_rs,$item_rs); } -sub _check_implicit_subscriber { +sub _check_implicit_user { my ($c, $params) = @_; - if ( - (none {defined $params->{$_}} qw/reseller_id customer_id subscriber_id/) && - (any {$c->user->roles eq $_} qw/subscriber subscriberadmin/) - ) { - $params->{subscriber_id} = $c->user->voip_subscriber->id; + if (none {defined $params->{$_}} qw/reseller_id customer_id subscriber_id/) { + if ($c->user->roles eq "reseller") { + $params->{reseller_id} = $c->user->reseller_id; + } + elsif (any {$c->user->roles eq $_} qw/subscriber subscriberadmin/) { + $params->{subscriber_id} = $c->user->voip_subscriber->id; + } } }