From 648954c6d36fe42172a8955e0b6cf992bbefb7be Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 26 Feb 2019 09:12:36 +0100 Subject: [PATCH] add optional list parameter to quarusers api call so that we can get the list of users of white or blacklist only Signed-off-by: Dominik Csapak --- PMG/API2/Quarantine.pm | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/PMG/API2/Quarantine.pm b/PMG/API2/Quarantine.pm index 157a51e..158247b 100644 --- a/PMG/API2/Quarantine.pm +++ b/PMG/API2/Quarantine.pm @@ -477,7 +477,14 @@ __PACKAGE__->register_method ({ description => "Get a list of users with whitelist/blacklist setttings.", parameters => { additionalProperties => 0, - properties => {}, + properties => { + list => { + type => 'string', + description => 'If set, limits the result to the given list.', + enum => ['BL', 'WL'], + optional => 1, + }, + }, }, returns => { type => 'array', @@ -501,10 +508,14 @@ __PACKAGE__->register_method ({ my $dbh = PMG::DBTools::open_ruledb(); - my $sth = $dbh->prepare( - "SELECT DISTINCT pmail FROM UserPrefs ORDER BY pmail"); - - $sth->execute(); + my $sth; + if ($param->{list}) { + $sth = $dbh->prepare("SELECT DISTINCT pmail FROM UserPrefs WHERE name = ? ORDER BY pmail"); + $sth->execute($param->{list}); + } else { + $sth = $dbh->prepare("SELECT DISTINCT pmail FROM UserPrefs ORDER BY pmail"); + $sth->execute(); + } while (my $ref = $sth->fetchrow_hashref()) { push @$res, { mail => $ref->{pmail} }; -- 2.39.2