From: Dominik Csapak Date: Tue, 26 Feb 2019 08:12:34 +0000 (+0100) Subject: user white/blacklist: allow multiple entries for adding/deleting X-Git-Url: https://git.proxmox.com/?p=pmg-api.git;a=commitdiff_plain;h=1a1bde133843fbd8e901502043a1880ddad2cb6e user white/blacklist: allow multiple entries for adding/deleting and reallow globs (like previously) like *.com entries are seperated by ',' Signed-off-by: Dominik Csapak --- diff --git a/PMG/API2/Quarantine.pm b/PMG/API2/Quarantine.pm index abcccdb..157a51e 100644 --- a/PMG/API2/Quarantine.pm +++ b/PMG/API2/Quarantine.pm @@ -253,7 +253,7 @@ __PACKAGE__->register_method ({ additionalProperties => 0, properties => { pmail => $pmail_param_type, - address => get_standard_option('pmg-email-address', { + address => get_standard_option('pmg-whiteblacklist-entry-list', { description => "The address you want to add.", }), }, @@ -262,7 +262,8 @@ __PACKAGE__->register_method ({ code => sub { my ($param) = @_; - $read_or_modify_user_bw_list->('WL', $param, [ $param->{address} ]); + my $addresses = [split(',', $param->{address})]; + $read_or_modify_user_bw_list->('WL', $param, $addresses); return undef; }}); @@ -278,7 +279,7 @@ __PACKAGE__->register_method ({ additionalProperties => 0, properties => { pmail => $pmail_param_type, - address => get_standard_option('pmg-email-address', { + address => get_standard_option('pmg-whiteblacklist-entry-list', { description => "The address you want to remove.", }), }, @@ -287,7 +288,8 @@ __PACKAGE__->register_method ({ code => sub { my ($param) = @_; - $read_or_modify_user_bw_list->('WL', $param, [ $param->{address} ], 1); + my $addresses = [split(',', $param->{address})]; + $read_or_modify_user_bw_list->('WL', $param, $addresses, 1); return undef; }}); @@ -332,7 +334,7 @@ __PACKAGE__->register_method ({ additionalProperties => 0, properties => { pmail => $pmail_param_type, - address => get_standard_option('pmg-email-address', { + address => get_standard_option('pmg-whiteblacklist-entry-list', { description => "The address you want to add.", }), }, @@ -341,7 +343,8 @@ __PACKAGE__->register_method ({ code => sub { my ($param) = @_; - $read_or_modify_user_bw_list->('BL', $param, [ $param->{address} ]); + my $addresses = [split(',', $param->{address})]; + $read_or_modify_user_bw_list->('BL', $param, $addresses); return undef; }}); @@ -357,7 +360,7 @@ __PACKAGE__->register_method ({ additionalProperties => 0, properties => { pmail => $pmail_param_type, - address => get_standard_option('pmg-email-address', { + address => get_standard_option('pmg-whiteblacklist-entry-list', { description => "The address you want to remove.", }), }, @@ -366,7 +369,8 @@ __PACKAGE__->register_method ({ code => sub { my ($param) = @_; - $read_or_modify_user_bw_list->('BL', $param, [ $param->{address} ], 1); + my $addresses = [split(',', $param->{address})]; + $read_or_modify_user_bw_list->('BL', $param, $addresses, 1); return undef; }}); diff --git a/PMG/Utils.pm b/PMG/Utils.pm index 60fdc5e..6847054 100644 --- a/PMG/Utils.pm +++ b/PMG/Utils.pm @@ -113,6 +113,13 @@ PVE::JSONSchema::register_standard_option('pmg-email-address', { minLength => 3, }); +PVE::JSONSchema::register_standard_option('pmg-whiteblacklist-entry-list', { + description => "White/Blacklist entry list (allow most characters). Can contain globs", + type => 'string', + pattern => '(?:[^\s\/\\\;\,]+)(?:\,[^\s\/\\\;\,]+)*', + minLength => 3, +}); + sub lastid { my ($dbh, $seq) = @_;