MT#56845 HG: introduce new field `Cancel Mode`

This field controls a behavior upon cancelling unsuccessful legs:
- terminate legs with CANCEL (default way)
- terminate legs with BYE

Change-Id: I2ff5c758c319714f0e6636db8b8ba5c0fd495e1f
mr12.0
Donat Zenichev 3 years ago
parent ba78e193e9
commit fd796a91ba

@ -395,6 +395,7 @@ sub base :Chained('list_customer') :PathPart('') :CaptureArgs(1) {
{ name => "provisioning_voip_subscriber.pbx_extension", search => 1, title => $c->loc("Extension") },
{ name => "provisioning_voip_subscriber.pbx_hunt_policy", search => 1, title => $c->loc("Hunt Policy") },
{ name => "provisioning_voip_subscriber.pbx_hunt_timeout", search => 1, title => $c->loc("Hunt Timeout") },
{ name => "provisioning_voip_subscriber.pbx_hunt_cancel_mode", search => 1, title => $c->loc("Cancel Mode") },
]);
my $subscribers_rs = $c->model('DB')->resultset('voip_subscribers')->search({
contract_id => $contract_id,
@ -1465,6 +1466,7 @@ sub pbx_group_create :Chained('base') :PathPart('pbx/group/create') :Args(0) {
$preferences->{cloud_pbx} = 1;
$preferences->{cloud_pbx_hunt_policy} = $form->values->{pbx_hunt_policy};
$preferences->{cloud_pbx_hunt_timeout} = $form->values->{pbx_hunt_timeout};
$preferences->{cloud_pbx_hunt_cancel_mode} = $form->values->{pbx_hunt_cancel_mode};
$preferences->{cloud_pbx_ext} = $form->values->{pbx_extension};
$preferences->{display_name} = ucfirst($form->values->{username});
my @events_to_create = ();
@ -1569,6 +1571,7 @@ sub pbx_group_edit :Chained('pbx_group_base') :PathPart('edit') :Args(0) {
pbx_extension => $form->values->{pbx_extension},
pbx_hunt_policy => $form->values->{pbx_hunt_policy},
pbx_hunt_timeout => $form->values->{pbx_hunt_timeout},
pbx_hunt_cancel_mode => $form->values->{pbx_hunt_cancel_mode},
});
NGCP::Panel::Utils::Subscriber::update_preferences(
c => $c,
@ -1576,6 +1579,7 @@ sub pbx_group_edit :Chained('pbx_group_base') :PathPart('edit') :Args(0) {
'preferences' => {
cloud_pbx_hunt_policy => $form->values->{pbx_hunt_policy},
cloud_pbx_hunt_timeout => $form->values->{pbx_hunt_timeout},
cloud_pbx_hunt_cancel_mode => $form->values->{pbx_hunt_cancel_mode},
}
);
my $e164;

@ -12,7 +12,7 @@ has_field 'username' => (
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/username pbx_extension pbx_hunt_policy pbx_hunt_timeout/],
render_list => [qw/username pbx_extension pbx_hunt_policy pbx_hunt_timeout pbx_hunt_cancel_mode/],
);
sub validate_username {

@ -38,6 +38,17 @@ has_field 'pbx_hunt_timeout' => (
default => 10,
);
has_field 'pbx_hunt_cancel_mode' => (
type => 'Select',
required => 1,
label => 'Cancel Mode',
options => [
{ label => 'Using Bye', value => 'bye' },
{ label => 'Using Cancel', value => 'cancel' },
],
default => 'cancel',
);
has_field 'save' => (
type => 'Submit',
value => 'Save',
@ -48,7 +59,7 @@ has_field 'save' => (
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/pbx_extension pbx_hunt_policy pbx_hunt_timeout/],
render_list => [qw/pbx_extension pbx_hunt_policy pbx_hunt_timeout pbx_hunt_cancel_mode/],
);
has_block 'actions' => (

@ -24,7 +24,7 @@ has_field 'alias_number_add' => (
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/pbx_extension pbx_hunt_policy pbx_hunt_timeout alias_number alias_number_add/],
render_list => [qw/pbx_extension pbx_hunt_policy pbx_hunt_timeout pbx_hunt_cancel_mode alias_number alias_number_add/],
);
1;

@ -18,7 +18,7 @@ has_field 'alias_select' => (
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/pbx_extension pbx_hunt_policy pbx_hunt_timeout alias_select/],
render_list => [qw/pbx_extension pbx_hunt_policy pbx_hunt_timeout pbx_hunt_cancel_mode alias_select/],
);
sub update_fields {

@ -123,7 +123,6 @@ has_field 'pbx_hunt_policy' => (
title => ["Hunting policy, one of serial, parallel, random, circular."],
},
);
has_field 'pbx_hunt_timeout' => (
type => '+NGCP::Panel::Field::PosInteger',
element_attr => {
@ -131,6 +130,18 @@ has_field 'pbx_hunt_timeout' => (
title => ['Hunting Timeout'],
},
);
has_field 'pbx_hunt_cancel_mode' => (
type => 'Select',
options => [
{ value => 'bye', label => 'bye'},
{ value => 'cancel', label => 'cancel'},
],
element_attr => {
rel => ['tooltip'],
title => ["Termination mode for call legs in the early dialog stage. Can be: bye or cancel."],
},
);
has_field 'cloud_pbx_hunt_policy' => (
type => 'Select',
options => [
@ -144,7 +155,6 @@ has_field 'cloud_pbx_hunt_policy' => (
title => ["Hunting policy, one of serial, parallel, random, circular."],
},
);
has_field 'cloud_pbx_hunt_timeout' => (
type => '+NGCP::Panel::Field::PosInteger',
element_attr => {
@ -152,6 +162,17 @@ has_field 'cloud_pbx_hunt_timeout' => (
title => ['Hunting Timeout'],
},
);
has_field 'cloud_pbx_hunt_cancel_mode' => (
type => 'Select',
options => [
{ value => 'bye', label => 'bye'},
{ value => 'cancel', label => 'cancel'},
],
element_attr => {
rel => ['tooltip'],
title => ["Termination mode for call legs in the early dialog stage. Can be: bye or cancel."],
},
);
has_field 'profile' => (
type => '+NGCP::Panel::Field::SubscriberProfile',

@ -252,6 +252,18 @@ has_field 'pbx_hunt_policy' => (
},
);
has_field 'pbx_hunt_cancel_mode' => (
type => 'Select',
options => [
{ value => 'bye', label => 'bye'},
{ value => 'cancel', label => 'cancel'},
],
element_attr => {
rel => ['tooltip'],
title => ["Termination mode for call legs in the early dialog stage. Can be: bye or cancel."],
},
);
has_field 'pbx_hunt_timeout' => (
type => '+NGCP::Panel::Field::PosInteger',
element_attr => {
@ -274,6 +286,18 @@ has_field 'cloud_pbx_hunt_policy' => (
},
);
has_field 'cloud_pbx_hunt_cancel_mode' => (
type => 'Select',
options => [
{ value => 'bye', label => 'bye'},
{ value => 'cancel', label => 'cancel'},
],
element_attr => {
rel => ['tooltip'],
title => ["Termination mode for call legs in the early dialog stage. Can be: bye or cancel."],
},
);
has_field 'cloud_pbx_hunt_timeout' => (
type => '+NGCP::Panel::Field::PosInteger',
element_attr => {

@ -67,6 +67,8 @@ sub resource_from_item {
delete $resource{cloud_pbx_hunt_policy};
delete $resource{pbx_hunt_timeout};
delete $resource{cloud_pbx_hunt_timeout};
delete $resource{pbx_hunt_cancel_mode};
delete $resource{cloud_pbx_hunt_cancel_mode};
}
delete $resource{contact_id};
if($item->contact) {
@ -540,12 +542,14 @@ sub update_item {
if(is_true($resource->{is_pbx_group})) {
$provisioning_res->{pbx_hunt_policy} = $resource->{pbx_hunt_policy};
$provisioning_res->{pbx_hunt_timeout} = $resource->{pbx_hunt_timeout};
$provisioning_res->{pbx_hunt_cancel_mode} = $resource->{pbx_hunt_cancel_mode};
NGCP::Panel::Utils::Subscriber::update_preferences(
c => $c,
prov_subscriber => $prov_subscriber,
'preferences' => {
cloud_pbx_hunt_policy => $resource->{cloud_pbx_hunt_policy} // $resource->{pbx_hunt_policy},
cloud_pbx_hunt_timeout => $resource->{cloud_pbx_hunt_policy} // $resource->{pbx_hunt_timeout},
cloud_pbx_hunt_timeout => $resource->{cloud_pbx_hunt_timeout} // $resource->{pbx_hunt_timeout},
cloud_pbx_hunt_cancel_mode => $resource->{cloud_pbx_hunt_cancel_mode} // $resource->{pbx_hunt_cancel_mode},
}
);
}

@ -170,6 +170,8 @@ sub localize {
$c->loc('The hunting policy for PBX hunt groups.');
$c->loc('CloudPBX Hunt Timeout');
$c->loc('The timeout for hunting in PBX hunt groups.');
$c->loc('CloudPBX Cancel Mode');
$c->loc('This is a termination mode for call legs in the early dialog stage. Can be: bye or cancel.');
$c->loc('CloudPBX Hunt Group List');
$c->loc('The members (as SIP URIs) of the PBX hunt group.');
$c->loc('CLI of CloudPBX Pilot Subscriber');

@ -418,7 +418,7 @@ sub prepare_resource {
my $preferences = {};
my $admin = 0;
unless($customer->product->class eq 'pbxaccount') {
for my $pref(qw/is_pbx_group pbx_extension pbx_hunt_policy pbx_hunt_timeout is_pbx_pilot/) {
for my $pref(qw/is_pbx_group pbx_extension pbx_hunt_policy pbx_hunt_timeout pbx_hunt_cancel_mode is_pbx_pilot/) {
delete $resource->{$pref};
}
$admin = $resource->{admin} // 0;
@ -510,8 +510,10 @@ sub prepare_resource {
if(is_true($resource->{is_pbx_group})) {
$preferences->{cloud_pbx_hunt_policy} = $resource->{cloud_pbx_hunt_policy};
$preferences->{cloud_pbx_hunt_timeout} = $resource->{cloud_pbx_hunt_timeout};
$preferences->{cloud_pbx_hunt_cancel_mode} = $resource->{pbx_hunt_cancel_mode};
$preferences->{cloud_pbx_hunt_policy} //= $resource->{pbx_hunt_policy};
$preferences->{cloud_pbx_hunt_timeout} //= $resource->{pbx_hunt_timeout};
$preferences->{cloud_pbx_hunt_cancel_mode} //= $resource->{pbx_hunt_cancel_mode};
}
$preferences->{cloud_pbx_ext} = $resource->{pbx_extension};
$preferences->{shared_buddylist_visibility} = 1;
@ -709,6 +711,7 @@ sub create_subscriber {
pbx_extension => $params->{pbx_extension},
pbx_hunt_policy => $params->{pbx_hunt_policy},
pbx_hunt_timeout => $params->{pbx_hunt_timeout},
pbx_hunt_cancel_mode => $params->{pbx_hunt_cancel_mode},
profile_set_id => $profile_set ? $profile_set->id : undef,
profile_id => $profile ? $profile->id : undef,
create_timestamp => NGCP::Panel::Utils::DateTime::current_local,

@ -160,6 +160,12 @@
[% subscriber.provisioning_voip_subscriber.pbx_hunt_timeout %]
</td>
</tr>
<tr>
<td>[% c.loc('Cancel Mode') %]</td>
<td>
[% subscriber.provisioning_voip_subscriber.pbx_hunt_cancel_mode %]
</td>
</tr>
[% END -%]
</tbody>
</table>

@ -52,6 +52,7 @@ $fake_data->set_data_from_script({
status => 'active',
pbx_hunt_policy => 'parallel',
pbx_hunt_timeout => '15',
pbx_hunt_cancel_mode => 'cancel',
},
'query' => [['username',{'query_type'=> 'string_like'}]],
'create_special'=> sub {

@ -183,6 +183,7 @@
status: 'active'
pbx_hunt_policy: 'parallel'
pbx_hunt_timeout: '15'
pbx_hunt_cancel_mode: 'cancel'
retain:
subscriber_path1: header.location
conditions:
@ -232,6 +233,7 @@
status: 'active'
pbx_hunt_policy: 'parallel'
pbx_hunt_timeout: '15'
pbx_hunt_cancel_mode: 'cancel'
retain:
subscriber_path2: header.location
conditions:
@ -277,6 +279,7 @@
status: 'active'
pbx_hunt_policy: 'parallel'
pbx_hunt_timeout: '15'
pbx_hunt_cancel_mode: 'cancel'
conditions:
is:
code: 422

Loading…
Cancel
Save