From 65ceb1acd81851fe4ba97fc91c3d32245d0d9515 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Thu, 5 Feb 2015 11:47:06 +0100 Subject: [PATCH] MT#10879 Fix fix of CLI handling on sub creation Change-Id: I61a1bf28f40c8ef08617c9520c38d52bb661d096 --- lib/NGCP/Panel/Utils/Subscriber.pm | 58 +++++++++++------------------- 1 file changed, 21 insertions(+), 37 deletions(-) diff --git a/lib/NGCP/Panel/Utils/Subscriber.pm b/lib/NGCP/Panel/Utils/Subscriber.pm index 354678c1ad..fff7d22ee7 100644 --- a/lib/NGCP/Panel/Utils/Subscriber.pm +++ b/lib/NGCP/Panel/Utils/Subscriber.pm @@ -222,20 +222,6 @@ sub create_subscriber { primary_number_id => undef, # will be filled in next step contact_id => $contact ? $contact->id : undef, }); - my ($cli); - if(defined $params->{e164}{cc} && $params->{e164}{cc} ne '') { - $cli = $params->{e164}{cc} . - ($params->{e164}{ac} || '') . - $params->{e164}{sn}; - - update_subscriber_numbers( - c => $c, - schema => $schema, - subscriber_id => $billing_subscriber->id, - reseller_id => $reseller->id, - primary_number => $params->{e164}, - ); - } unless(exists $params->{password}) { my ($pass_bin, $pass_str); UUID::generate($pass_bin); @@ -260,41 +246,39 @@ sub create_subscriber { profile_id => $profile ? $profile->id : undef, create_timestamp => NGCP::Panel::Utils::DateTime::current_local, }); + my ($cli); + if(defined $params->{e164}{cc} && $params->{e164}{cc} ne '') { + $cli = $params->{e164}{cc} . + ($params->{e164}{ac} || '') . + $params->{e164}{sn}; + + update_subscriber_numbers( + c => $c, + schema => $schema, + subscriber_id => $billing_subscriber->id, + reseller_id => $reseller->id, + primary_number => $params->{e164}, + ); + } + $schema->resultset('voicemail_users')->create({ + customer_id => $uuid_string, + mailbox => $cli // $uuid_string, + password => sprintf("%04d", int(rand 10000)), + email => '', + tz => 'vienna', + }); $preferences->{account_id} = $contract->id; $preferences->{ac} = $params->{e164}{ac} if(defined $params->{e164}{ac} && length($params->{e164}{ac}) > 0); $preferences->{cc} = $params->{e164}{cc} if(defined $params->{e164}{cc} && length($params->{e164}{cc}) > 0); - $preferences->{cli} = $cli - if(defined $cli); update_preferences(c => $c, prov_subscriber => $prov_subscriber, preferences => $preferences ); - $schema->resultset('voicemail_users')->create({ - customer_id => $uuid_string, - mailbox => $cli // 0, - password => sprintf("%04d", int(rand 10000)), - email => '', - tz => 'vienna', - }); - if($cli) { - $schema->resultset('voip_dbaliases')->create({ - username => $cli, - domain_id => $prov_subscriber->domain->id, - subscriber_id => $prov_subscriber->id, - is_primary => 1, - }); - if($c->config->{numbermanagement}->{auto_allow_cli}) { - my $pref = NGCP::Panel::Utils::Preferences::get_usr_preference_rs( - c => $c, attribute => 'allowed_clis', prov_subscriber => $prov_subscriber); - $pref->create({ value => $cli }) if(defined $pref); - } - } - if($contract->subscriber_email_template_id) { my ($uuid_bin, $uuid_string); UUID::generate($uuid_bin);