From 9867e2da06b9a511f033c4848a847dd97280bd31 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 24 Aug 2017 07:21:08 +0200 Subject: [PATCH] add API to query UserPrefs --- PMG/API2/Quarantine.pm | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/PMG/API2/Quarantine.pm b/PMG/API2/Quarantine.pm index 7981ae2..1616bda 100644 --- a/PMG/API2/Quarantine.pm +++ b/PMG/API2/Quarantine.pm @@ -430,6 +430,51 @@ __PACKAGE__->register_method ({ return $res; }}); +__PACKAGE__->register_method ({ + name => 'quarusers', + path => 'quarusers', + method => 'GET', + permissions => { check => [ 'admin', 'qmanager', 'audit'] }, + description => "Get a list of users with whitelist/blacklist setttings.", + parameters => { + additionalProperties => 0, + properties => {}, + }, + returns => { + type => 'array', + items => { + type => "object", + properties => { + mail => { + description => 'the receiving email', + type => 'string', + }, + }, + }, + }, + code => sub { + my ($param) = @_; + + my $rpcenv = PMG::RESTEnvironment->get(); + my $authuser = $rpcenv->get_user(); + my $role = $rpcenv->get_role(); + + my $res = []; + + my $dbh = PMG::DBTools::open_ruledb(); + + my $sth = $dbh->prepare( + "SELECT DISTINCT pmail FROM UserPrefs ORDER BY pmail"); + + $sth->execute(); + + while (my $ref = $sth->fetchrow_hashref()) { + push @$res, { mail => $ref->{pmail} }; + } + + return $res; + }}); + __PACKAGE__->register_method ({ name => 'spam', path => 'spam', -- 2.39.5