diff options
Diffstat (limited to 'Bugzilla/Config/Admin.pm')
-rw-r--r-- | Bugzilla/Config/Admin.pm | 107 |
1 files changed, 44 insertions, 63 deletions
diff --git a/Bugzilla/Config/Admin.pm b/Bugzilla/Config/Admin.pm index ac1c4ca0e..cae4cb25d 100644 --- a/Bugzilla/Config/Admin.pm +++ b/Bugzilla/Config/Admin.pm @@ -19,78 +19,59 @@ use Scalar::Util qw(looks_like_number); our $sortkey = 200; sub get_param_list { - my $class = shift; - my @param_list = ( - { - name => 'allowbugdeletion', - type => 'b', - default => 0 - }, - - { - name => 'allowemailchange', - type => 'b', - default => 1 - }, - - { - name => 'allowuserdeletion', - type => 'b', - default => 0 - }, - - { - name => 'last_visit_keep_days', - type => 't', - default => 10, - checker => \&check_numeric - }, - - { - name => 'rate_limit_active', - type => 'b', - default => 1, - }, - - { - name => 'rate_limit_rules', - type => 'l', - default => '{"get_bug": [75, 60], "show_bug": [75, 60], "github": [10, 60]}', - checker => \&check_rate_limit_rules, - updater => \&update_rate_limit_rules, - }, - - { - name => 'log_user_requests', - type => 'b', - default => 0, - } - ); - return @param_list; + my $class = shift; + my @param_list = ( + {name => 'allowbugdeletion', type => 'b', default => 0}, + + {name => 'allowemailchange', type => 'b', default => 1}, + + {name => 'allowuserdeletion', type => 'b', default => 0}, + + { + name => 'last_visit_keep_days', + type => 't', + default => 10, + checker => \&check_numeric + }, + + {name => 'rate_limit_active', type => 'b', default => 1,}, + + { + name => 'rate_limit_rules', + type => 'l', + default => '{"get_bug": [75, 60], "show_bug": [75, 60], "github": [10, 60]}', + checker => \&check_rate_limit_rules, + updater => \&update_rate_limit_rules, + }, + + {name => 'log_user_requests', type => 'b', default => 0,} + ); + return @param_list; } sub check_rate_limit_rules { - my $rules = shift; + my $rules = shift; - my $val = eval { decode_json($rules) }; - return "failed to parse json" unless defined $val; - return "value is not HASH" unless ref $val && ref($val) eq 'HASH'; - return "rules are invalid" unless all { - ref($_) eq 'ARRAY' && looks_like_number( $_->[0] ) && looks_like_number( $_->[1] ) - } values %$val; + my $val = eval { decode_json($rules) }; + return "failed to parse json" unless defined $val; + return "value is not HASH" unless ref $val && ref($val) eq 'HASH'; + return "rules are invalid" unless all { + ref($_) eq 'ARRAY' && looks_like_number($_->[0]) && looks_like_number($_->[1]) + } + values %$val; - foreach my $required (qw( show_bug get_bug github )) { - return "missing $required" unless exists $val->{$required}; - } + foreach my $required (qw( show_bug get_bug github )) { + return "missing $required" unless exists $val->{$required}; + } - return ""; + return ""; } sub update_rate_limit_rules { - my ($rules) = @_; - my $val = decode_json($rules); - $val->{github} = [10, 60]; - return encode_json($val); + my ($rules) = @_; + my $val = decode_json($rules); + $val->{github} = [10, 60]; + return encode_json($val); } 1; |