TT#37206 is_regexp flag for callforwardings

implemented for Source Sets and B-Number Set in:
* Panel
* /api/cfbnumbersets/
* /api/cfsourcesets/
* /api/callforwards/

in addition, the fields have also been documented in the forms (and therefore
also in the API documentation)

Change-Id: I955dd9addf1e61ec7516b4c518adec151248bacc
changes/71/22371/1
Gerhard Jungwirth 8 years ago
parent 2431c0efd9
commit 9210ac0487

@ -76,6 +76,7 @@ sub create_item {
$bset = $schema->resultset('voip_cf_bnumber_sets')->create({
name => $resource->{name},
mode => $resource->{mode},
is_regex => $resource->{is_regex} // 0,
subscriber_id => $subscriber->id,
});
for my $s ( @{$resource->{bnumbers}} ) {

@ -169,6 +169,7 @@ sub POST :Allow {
$sset = $schema->resultset('voip_cf_source_sets')->create({
name => $resource->{name},
mode => $resource->{mode},
is_regex => $resource->{is_regex} // 0,
subscriber_id => $subscriber->id,
});
for my $s ( @{$resource->{sources}} ) {

@ -1635,6 +1635,7 @@ sub preferences_callforward_sourceset_create :Chained('base') :PathPart('prefere
my $set = $prov_subscriber->voip_cf_source_sets->create({
name => $form->field('name')->value,
mode => $form->field('mode')->value,
is_regex => $form->field('is_regex')->value,
});
foreach my $src(@fields) {
my $s = $src->field('source')->value;
@ -1710,6 +1711,7 @@ sub preferences_callforward_sourceset_edit :Chained('preferences_callforward_sou
unless($posted) {
$params->{name} = $set->name;
$params->{mode} = $set->mode;
$params->{is_regex} = $set->is_regex;
my @sources;
for my $src($set->voip_cf_sources->all) {
push @sources, {
@ -1757,6 +1759,9 @@ sub preferences_callforward_sourceset_edit :Chained('preferences_callforward_sou
if($form->field('mode')->value ne $set->mode) {
$set->update({mode => $form->field('mode')->value});
}
if($form->field('is_regex')->value ne $set->is_regex) {
$set->update({is_regex => $form->field('is_regex')->value});
}
$set->voip_cf_sources->delete_all;
foreach my $src(@fields) {
@ -1905,6 +1910,7 @@ sub preferences_callforward_bnumberset_create :Chained('base') :PathPart('prefer
my $set = $prov_subscriber->voip_cf_bnumber_sets->create({
name => $form->field('name')->value,
mode => $form->field('mode')->value,
is_regex => $form->field('is_regex')->value,
});
foreach my $bnum_row(@fields) {
my $s = $bnum_row->field('number')->value;
@ -1980,6 +1986,7 @@ sub preferences_callforward_bnumberset_edit :Chained('preferences_callforward_bn
unless($posted) {
$params->{name} = $set->name;
$params->{mode} = $set->mode;
$params->{is_regex} = $set->is_regex;
my @numbers;
for my $bnum_rows($set->voip_cf_bnumbers->all) {
push @numbers, {
@ -2028,6 +2035,9 @@ sub preferences_callforward_bnumberset_edit :Chained('preferences_callforward_bn
if($form->field('mode')->value ne $set->mode) {
$set->update({mode => $form->field('mode')->value});
}
if($form->field('is_regex')->value ne $set->is_regex) {
$set->update({is_regex => $form->field('is_regex')->value});
}
$set->voip_cf_bnumbers->delete_all;
foreach my $src(@fields) {

@ -46,6 +46,11 @@ has_field 'sources_mode' => (
default => 'whitelist',
);
has_field 'sources_is_regex' => (
type => 'Boolean',
default => 0,
);
has_field 'bnumbers' => (
type => 'Repeatable',
do_wrapper => 1,
@ -65,6 +70,11 @@ has_field 'bnumbers_mode' => (
default => 'whitelist',
);
has_field 'bnumbers_is_regex' => (
type => 'Boolean',
default => 0,
);
no Moose;
1;

@ -28,6 +28,20 @@ has_field 'mode' => (
},
);
has_field 'is_regex' => (
type => 'Boolean',
default => 0,
element_attr => {
rel => ['tooltip'],
title => ['A flag indicating, whether the numbers in this set are regular expressions. ' .
'If true, all bnumbers will be interepreted as perl compatible regular expressions and ' .
'matched against the B-Number of the calls. If false, shell pattern the whole numbers ' .
'are matched while shell patterns like 431* or 49123~[1-5~]67 are possible. ' .
'If true, capturing groups can be formed using parentheses and referenced in the ' .
'destinations via \\1, \\2,... .'],
},
);
has_field 'bnumbers' => (
type => 'Repeatable',
element_attr => {
@ -36,7 +50,8 @@ has_field 'bnumbers' => (
'which will be matched against the called party number (callee) to determine ' .
'whether to apply the callforward or not. ' .
'"bnumber" is the callee\'s number in E164 format to match. ' .
'Shell patterns like 431* or 49123~[1-5~]67 are possible.',
'They are formatted either as regular expressions or shell patterns depending on the ' .
'value of the is_regex flag.',
],
},
);

@ -28,6 +28,18 @@ has_field 'mode' => (
},
);
has_field 'is_regex' => (
type => 'Boolean',
default => 0,
element_attr => {
rel => ['tooltip'],
title => ['A flag indicating, whether the numbers in this set are regular expressions. ' .
'If true, all sources will be interepreted as perl compatible regular expressions and ' .
'matched against the calling party number (in E164 format) of the calls. If false, the whole numbers ' .
'are plainly matched while shell patterns like 431* or 49123~[1-5~]67 are possible.'],
},
);
has_field 'sources' => (
type => 'Repeatable',
element_attr => {
@ -36,7 +48,7 @@ has_field 'sources' => (
'which will be matched against the calling party number to determine ' .
'whether to apply the callforward or not. ' .
'"source" is the calling party number in E164 format to match. ' .
'Shell patterns like 431* or 49123~[1-5~]67 are possible. ' .
'Regular expressions or shell patterns can be used depending on the is_regex flag. ' .
'Use "anonymous" to match suppressed numbers.',
],
},

@ -34,6 +34,18 @@ has_field 'mode' => (
},
);
has_field 'is_regex' => (
type => 'Boolean',
default => 0,
element_attr => {
rel => ['tooltip'],
title => ['A flag indicating, whether the numbers in this set are regular expressions. ' .
'If true, all bnumbers will be interepreted as perl compatible regular expressions and ' .
'matched against the B-Number of the calls. If false, shell pattern the whole numbers ' .
'are matched while shell patterns like 431* or 49123~[1-5~]67 are possible.'],
},
);
has_field 'bnumbers' => (
type => 'Repeatable',
setup_for_js => 1,
@ -59,7 +71,8 @@ has_field 'bnumbers.number' => (
element_attr => {
rel => ['tooltip'],
title => ['Matches the B-Number (original number dialled by the caller) in E164 format. ' .
'Shell patterns like 431* or 49123~[1-5~]67 are possible.'],
'They are formatted either as regular expressions or shell patterns depending on the' .
'value of the is_regex flag.'],
},
);
@ -82,7 +95,7 @@ has_field 'bnumber_add' => (
has_block 'fields' => (
tag => 'div',
class => [qw(modal-body)],
render_list => [qw(name mode bnumbers bnumber_add)],
render_list => [qw(name mode is_regex bnumbers bnumber_add)],
);
has_field 'save' => (

@ -34,6 +34,20 @@ has_field 'mode' => (
},
);
has_field 'is_regex' => (
type => 'Boolean',
default => 0,
element_attr => {
rel => ['tooltip'],
title => ['A flag indicating, whether the numbers in this set are regular expressions. ' .
'If true, all sources will be interepreted as perl compatible regular expressions and ' .
'matched against the calling party number (in E164 format) of the calls. If false, the whole numbers ' .
'are plainly matched while shell patterns like 431* or 49123~[1-5~]67 are possible. ' .
'If true, capturing groups can be formed using parentheses and referenced in the ' .
'destinations via \\1, \\2,... .'],
},
);
has_field 'source' => (
type => 'Repeatable',
setup_for_js => 1,
@ -58,7 +72,8 @@ has_field 'source.source' => (
wrapper_class => [qw/hfh-rep-field/],
element_attr => {
rel => ['tooltip'],
title => ['The calling party number in E164 format to match. Shell patterns like 431* or 49123~[1-5~]67 are possible. ' .
title => ['The calling party number in E164 format to match. Regular expressions ' .
'or shell patterns can be used depending on the is_regex flag. ' .
'Use "anonymous" to match suppressed numbers.'],
},
);
@ -82,7 +97,7 @@ has_field 'source_add' => (
has_block 'fields' => (
tag => 'div',
class => [qw(modal-body)],
render_list => [qw(name mode source source_add)],
render_list => [qw(name mode is_regex source source_add)],
);
has_field 'save' => (

@ -141,6 +141,7 @@ sub update_item {
$item->update({
name => $resource->{name},
mode => $resource->{mode},
(defined $resource->{is_regex} ? (is_regex => $resource->{is_regex}) : ()),
subscriber_id => $subscriber->id,
})->discard_changes;
$item->voip_cf_bnumbers->delete;

@ -148,6 +148,7 @@ sub update_item {
$item->update({
name => $resource->{name},
mode => $resource->{mode},
(defined $resource->{is_regex} ? (is_regex => $resource->{is_regex}) : ()),
subscriber_id => $subscriber->id,
})->discard_changes;
$item->voip_cf_sources->delete;

@ -304,10 +304,18 @@ sub update_item {
$sset->mode ne $resource->{$type}{sources_mode}) {
$sset->update({mode => $resource->{$type}{sources_mode}});
}
if (@{ $resource->{$type}{sources} } > 0 &&
$sset->is_regex ne $resource->{$type}{sources_is_regex}) {
$sset->update({is_regex => $resource->{$type}{sources_is_regex}});
}
if (@{ $resource->{$type}{bnumbers} } > 0 &&
$bset->mode ne $resource->{$type}{bnumbers_mode}) {
$bset->update({mode => $resource->{$type}{bnumbers_mode}});
}
if (@{ $resource->{$type}{bnumbers} } > 0 &&
$bset->is_regex ne $resource->{$type}{bnumbers_is_regex}) {
$bset->update({is_regex => $resource->{$type}{bnumbers_is_regex}});
}
$dset->discard_changes if $dset; # update destinations
my $new_autoattendant = NGCP::Panel::Utils::Subscriber::check_dset_autoattendant_status($dset);
@ -355,8 +363,10 @@ sub _contents_from_cfm {
my $dset_item = $cfm_item->destination_set;
my $sourceset_item = $cfm_item->source_set;
my $sourceset_mode = $sourceset_item ? $sourceset_item->mode : 'whitelist';
my $sourceset_is_regex = $sourceset_item ? $sourceset_item->is_regex : 0;
my $bnumberset_item = $cfm_item->bnumber_set;
my $bnumberset_mode = $bnumberset_item ? $bnumberset_item->mode : 'whitelist';
my $bnumberset_is_regex = $bnumberset_item ? $bnumberset_item->is_regex : 0;
for my $time ($timeset_item ? $timeset_item->voip_cf_periods->all : () ) {
push @times, {$time->get_inflated_columns};
delete @{$times[-1]}{'time_set_id', 'id'};
@ -383,8 +393,8 @@ sub _contents_from_cfm {
delete @{$bnumbers[-1]}{'bnumber_set_id', 'id'};
}
return {times => \@times, destinations => \@destinations,
sources => \@sources, sources_mode => $sourceset_mode,
bnumbers => \@bnumbers, bnumbers_mode => $bnumberset_mode};
sources => \@sources, sources_mode => $sourceset_mode, sources_is_regex => $sourceset_is_regex,
bnumbers => \@bnumbers, bnumbers_mode => $bnumberset_mode, bnumbers_is_regex => $bnumberset_is_regex};
}
1;

Loading…
Cancel
Save