TT#171850 fix unintentional primary number removal

* the current condition for primary number removal for PUT/PATCH is if
  the primary number exists and specified in the data as
  primary_number => undef. The condition failed as the 'primary_number'
  key was explicitly created regardless of the original user data input,
  resulting in a false primary_number => undef.

Change-Id: I17651046627f5c48696c3f1d17da5aa49452fe9a
mr11.0
Kirill Solomko 3 years ago
parent 77602745a7
commit 6bdfca9112

@ -489,7 +489,7 @@ sub update_item {
NGCP::Panel::Utils::Subscriber::update_subscriber_numbers(
c => $c,
schema => $schema,
primary_number => $resource->{e164},
exists $resource->{e164} ? (primary_number => $resource->{e164}) : (),
alias_numbers => $alias_numbers,
reseller_id => $customer->contact->reseller_id,
subscriber_id => $subscriber->id,

@ -288,7 +288,9 @@ sub prepare_resource {
$resource->{administrative} = $item ? $item->provisioning_voip_subscriber->admin : 0;
}
$resource->{e164} = delete $resource->{primary_number};
if (exists $resource->{primary_number}) {
$resource->{e164} = delete $resource->{primary_number};
}
$resource->{status} //= 'active';
$resource->{administrative} //= 0;
$resource->{is_pbx_pilot} //= 0;
@ -1543,7 +1545,7 @@ sub update_subscriber_numbers {
$alias->{e164}->{is_devid} = delete $alias->{is_devid};
}
if ($current_primary_number == $cli) {
if (defined $current_primary_number && $current_primary_number == $cli) {
die "alias '" . $c->qs($cli) . "' is already defined as the primary number";
}

Loading…
Cancel
Save