From 05eb8f6ec146ed265d97332008fbce32d5302a51 Mon Sep 17 00:00:00 2001 From: Rene Krenn Date: Wed, 25 Jan 2017 13:10:43 +0100 Subject: [PATCH] TT#8878 end_ivr event upon terminating a susbcriber Change-Id: I69b72ed18174eed19bb41c3a9b78f680aa1c0ee4 --- lib/NGCP/Panel/Utils/Subscriber.pm | 13 +++++++++++++ t/api-rest/api-events.t | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/lib/NGCP/Panel/Utils/Subscriber.pm b/lib/NGCP/Panel/Utils/Subscriber.pm index 847a6667e2..bab89f5343 100644 --- a/lib/NGCP/Panel/Utils/Subscriber.pm +++ b/lib/NGCP/Panel/Utils/Subscriber.pm @@ -1014,6 +1014,19 @@ sub terminate { my $schema = $c->model('DB'); $schema->txn_do(sub { my $prov_subscriber = $subscriber->provisioning_voip_subscriber; + if($prov_subscriber) { + foreach my $set ($prov_subscriber->voip_cf_destination_sets->all) { + my $autoattendant = check_dset_autoattendant_status($set); + if ($autoattendant) { + foreach my $map ($set->voip_cf_mappings->all) { + NGCP::Panel::Utils::Events::insert( + c => $c, schema => $schema, + subscriber => $subscriber, type => 'end_ivr', + ); + } + } + } + } if($prov_subscriber && $prov_subscriber->profile_id) { NGCP::Panel::Utils::Events::insert( c => $c, schema => $schema, diff --git a/t/api-rest/api-events.t b/t/api-rest/api-events.t index 3d906c625b..ac193614e1 100644 --- a/t/api-rest/api-events.t +++ b/t/api-rest/api-events.t @@ -218,6 +218,27 @@ my %customer_map = (); } +{ + my $customer = _create_customer( + type => "sipaccount", + ); + my $subscriber = _create_subscriber($customer, + primary_number => { cc => 888, ac => '3'.(scalar keys %subscriber_map), sn => $t }, + ); + + my $call_forwards = set_callforwards($subscriber,{ cfu => { + destinations => [ + { destination => "5678" }, + { destination => "autoattendant", }, + ], + }}); + _update_subscriber($subscriber, status => 'terminated'); + _check_event_history("events generated terminating the susbcriber: ",$subscriber->{id},"%ivr",[ + { subscriber_id => $subscriber->{id}, type => "start_ivr" }, + { subscriber_id => $subscriber->{id}, type => "end_ivr" }, + ]); +} + #SKIP: {