]> git.proxmox.com Git - pmg-api.git/commitdiff
user white/blacklist: allow multiple entries for adding/deleting
authorDominik Csapak <d.csapak@proxmox.com>
Tue, 26 Feb 2019 08:12:34 +0000 (09:12 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 26 Feb 2019 09:49:39 +0000 (10:49 +0100)
and reallow globs (like previously) like *.com
entries are seperated by ','

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
PMG/API2/Quarantine.pm
PMG/Utils.pm

index abcccdb099d114aed2c8b466c0695db458994727..157a51e8a628cbd749fe5ee924f9ba1467b08d59 100644 (file)
@@ -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;
     }});
index 60fdc5e5d353933e7943c0bc72eec36929ec0595..6847054a51c7d6331223cc2da6632c9545705b2a 100644 (file)
@@ -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) = @_;