From 51640b7156445f713ffcb64b02b451e3eccf4a26 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Mon, 16 Jun 2014 11:55:32 +0200 Subject: [PATCH] MT#7377 API: check for pilot primary_number. Before adding pbx_extension, check if pilot has a primary number. --- lib/NGCP/Panel/Role/API/Subscribers.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/NGCP/Panel/Role/API/Subscribers.pm b/lib/NGCP/Panel/Role/API/Subscribers.pm index 52a372ff9c..bf1f363dd7 100644 --- a/lib/NGCP/Panel/Role/API/Subscribers.pm +++ b/lib/NGCP/Panel/Role/API/Subscribers.pm @@ -321,6 +321,12 @@ sub prepare_resource { return; } + unless($pilot->primary_number) { + $c->log->error("trying to add pbx_extension to contract id " . $pilot->contract_id . " without having a primary number on pilot subscriber id " . $pilot->id); + $self->error($c, HTTP_UNPROCESSABLE_ENTITY, "The pilot subscriber does not have a primary number."); + return; + } + $resource->{e164}->{cc} = $pilot->primary_number->cc; $resource->{e164}->{ac} = $pilot->primary_number->ac // ''; $resource->{e164}->{sn} = $pilot->primary_number->sn . $resource->{pbx_extension};