From: Dominik Csapak <d.csapak@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api 1/1] fix #3287: add pmail parameter to virus/attch. quarantine list
Date: Wed, 23 Nov 2022 15:52:21 +0100 [thread overview]
Message-ID: <20221123145222.834345-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20221123145222.834345-1-d.csapak@proxmox.com>
so that we can filter by the recipient email
for that we also have to add the quarantine type to the 'spamusers' api
call, or else we cannot list which recipients have mails in the
respective quarantine
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/PMG/API2/Quarantine.pm | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/PMG/API2/Quarantine.pm b/src/PMG/API2/Quarantine.pm
index ddf7c04..71aaf0c 100644
--- a/src/PMG/API2/Quarantine.pm
+++ b/src/PMG/API2/Quarantine.pm
@@ -389,6 +389,12 @@ __PACKAGE__->register_method ({
}});
+my $quar_type_map = {
+ spam => 'S',
+ attachment => 'A',
+ virus => 'V',
+};
+
__PACKAGE__->register_method ({
name => 'spamusers',
path => 'spamusers',
@@ -400,6 +406,13 @@ __PACKAGE__->register_method ({
properties => {
starttime => get_standard_option('pmg-starttime'),
endtime => get_standard_option('pmg-endtime'),
+ 'quarantine-type' => {
+ description => 'Query this type of quarantine for users.',
+ type => 'string',
+ default => 'spam',
+ optional => 1,
+ enum => [keys $quar_type_map->%*],
+ },
},
},
returns => {
@@ -427,14 +440,16 @@ __PACKAGE__->register_method ({
my $start = $param->{starttime} // (time - 86400);
my $end = $param->{endtime} // ($start + 86400);
+ my $quar_type = $param->{'quarantine-type'} // 'spam';
+
my $sth = $dbh->prepare(
"SELECT DISTINCT pmail " .
"FROM CMailStore, CMSReceivers WHERE " .
"time >= $start AND time < $end AND " .
- "QType = 'S' AND CID = CMailStore_CID AND RID = CMailStore_RID " .
+ "QType = ? AND CID = CMailStore_CID AND RID = CMailStore_RID " .
"AND Status = 'N' ORDER BY pmail");
- $sth->execute();
+ $sth->execute($quar_type_map->{$quar_type});
while (my $ref = $sth->fetchrow_hashref()) {
push @$res, { mail => $ref->{pmail} };
@@ -657,6 +672,7 @@ __PACKAGE__->register_method ({
properties => {
starttime => get_standard_option('pmg-starttime'),
endtime => get_standard_option('pmg-endtime'),
+ pmail => $pmail_param_type,
},
},
returns => {
@@ -706,7 +722,7 @@ __PACKAGE__->register_method ({
},
code => sub {
my ($param) = @_;
- return $quarantine_api->($param, 'V');
+ return $quarantine_api->($param, 'V', defined($param->{pmail}));
}});
__PACKAGE__->register_method ({
@@ -720,6 +736,7 @@ __PACKAGE__->register_method ({
properties => {
starttime => get_standard_option('pmg-starttime'),
endtime => get_standard_option('pmg-endtime'),
+ pmail => $pmail_param_type,
},
},
returns => {
@@ -765,7 +782,7 @@ __PACKAGE__->register_method ({
},
code => sub {
my ($param) = @_;
- return $quarantine_api->($param, 'A');
+ return $quarantine_api->($param, 'A', defined($param->{pmail}));
}});
__PACKAGE__->register_method ({
--
2.30.2
next prev parent reply other threads:[~2022-11-23 14:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-23 14:52 [pmg-devel] [PATCH pmg-api/pmg-gui] fix #3287: allow filtering by mail for all qurantine views Dominik Csapak
2022-11-23 14:52 ` Dominik Csapak [this message]
2022-11-24 13:23 ` [pmg-devel] applied: [PATCH pmg-api 1/1] fix #3287: add pmail parameter to virus/attch. quarantine list Thomas Lamprecht
2022-11-23 14:52 ` [pmg-devel] [PATCH pmg-gui 1/1] fix #3287: add recipient filter for virus/attach. quarantine view Dominik Csapak
2022-11-25 14:26 ` [pmg-devel] applied: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221123145222.834345-2-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox