};
my $verify_optional_pmail = sub {
- my ($authuser, $role, $pmail) = @_;
+ my ($authuser, $role, $pmail_param) = @_;
+ my $pmail;
if ($role eq 'quser') {
- raise_param_exc({ pmail => "parameter not allwed with role '$role'"})
- if defined($pmail) && ($pmail ne $authuser);
$pmail = $extract_pmail->($authuser, $role);
+ raise_param_exc({ pmail => "parameter not allwed with role '$role'"})
+ if defined($pmail_param) && ($pmail ne $pmail_param);
} else {
raise_param_exc({ pmail => "parameter required with role '$role'"})
- if !defined($pmail);
+ if !defined($pmail_param);
+ $pmail = $pmail_param;
}
return $pmail;
};
$res->{envelope_sender} = $ref->{sender};
$res->{receiver} = $ref->{receiver} // $ref->{pmail};
- $res->{id} = 'C' . $ref->{cid} . 'R' . $ref->{rid};
+ $res->{id} = 'C' . $ref->{cid} . 'R' . $ref->{rid} . 'T' . $ref->{ticketid};
$res->{time} = $ref->{time};
$res->{bytes} = $ref->{bytes};
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.",
}),
},
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;
}});
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.",
}),
},
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;
}});
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.",
}),
},
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;
}});
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.",
}),
},
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;
}});
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',
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} };
id => {
description => 'Unique ID',
type => 'string',
- pattern => 'C\d+R\d+',
- maxLength => 40,
+ pattern => 'C\d+R\d+T\d+',
+ maxLength => 60,
},
raw => {
- description => "Display 'raw' eml data. This is only used with the 'htmlmail' formatter.",
+ description => "Display 'raw' eml data. Deactivates size limit.",
type => 'boolean',
optional => 1,
default => 0,
my $role = $rpcenv->get_role();
my $format = $rpcenv->get_format();
- my ($cid, $rid) = $param->{id} =~ m/^C(\d+)R(\d+)$/;
+ my $raw = $param->{raw} // 0;
+
+ my ($cid, $rid, $tid) = $param->{id} =~ m/^C(\d+)R(\d+)T(\d+)$/;
$cid = int($cid);
$rid = int($rid);
-
- my $pmail = $role eq 'quser' ? $extract_pmail->($authuser, $role) : undef;
+ $tid = int($tid);
my $dbh = PMG::DBTools::open_ruledb();
- my $ref = PMG::DBTools::load_mail_data($dbh, $cid, $rid, $pmail);
+ my $ref = PMG::DBTools::load_mail_data($dbh, $cid, $rid, $tid);
if ($role eq 'quser') {
my $quar_username = $ref->{pmail} . '@quarantine';
- raise_perm_exc("mail does not belong to user '$authuser' ($ref->{pmail}, $pmail)")
+ raise_perm_exc("mail does not belong to user '$authuser' ($ref->{pmail})")
if $authuser ne $quar_username;
}
my $res = $parse_header_info->($ref);
-
my $filename = $ref->{file};
my $spooldir = $PMG::MailQueue::spooldir;
my $viewimages = $cfg->get('spamquar', 'viewimages');
my $allowhref = $cfg->get('spamquar', 'allowhrefs');
- $res->{content} = PMG::HTMLMail::email_to_html($path, $param->{raw}, $viewimages, $allowhref);
+ $res->{content} = PMG::HTMLMail::email_to_html($path, $raw, $viewimages, $allowhref);
# to make result verification happy
$res->{file} = '';
} else {
# include additional details
- my ($header, $content) = PMG::HTMLMail::read_raw_email($path, 4096);
+ # we want to get the whole email in raw mode
+ my $maxbytes = (!$raw)? 4096 : undef;
+
+ my ($header, $content) = PMG::HTMLMail::read_raw_email($path, $maxbytes);
$res->{file} = $ref->{file};
$res->{spaminfo} = decode_spaminfo($ref->{info});
parameters => {
additionalProperties => 0,
properties => {
- pmail => $pmail_param_type,
id => {
- description => 'Unique ID',
+ description => 'Unique IDs, seperate with ;',
type => 'string',
- pattern => 'C\d+R\d+',
- maxLength => 40,
+ pattern => 'C\d+R\d+T\d+(;C\d+R\d+T\d+)*',
},
action => {
description => 'Action - specify what you want to do with the mail.',
my $authuser = $rpcenv->get_user();
my $role = $rpcenv->get_role();
my $action = $param->{action};
-
- my ($cid, $rid) = $param->{id} =~ m/^C(\d+)R(\d+)$/;
- $cid = int($cid);
- $rid = int($rid);
-
- my $pmail = $verify_optional_pmail->($authuser, $role, $param->{pmail});
+ my @idlist = split(';', $param->{id});
my $dbh = PMG::DBTools::open_ruledb();
- my $ref = PMG::DBTools::load_mail_data($dbh, $cid, $rid, $pmail);
+ for my $id (@idlist) {
+ my ($cid, $rid, $tid) = $id =~ m/^C(\d+)R(\d+)T(\d+)$/;
+ $cid = int($cid);
+ $rid = int($rid);
+ $tid = int($tid);
- if ($role eq 'quser') {
- my $quar_username = $ref->{pmail} . '@quarantine';
- raise_perm_exc("mail does not belong to user '$authuser' ($ref->{pmail}, $pmail)")
- if $authuser ne $quar_username;
- }
+ my $ref = PMG::DBTools::load_mail_data($dbh, $cid, $rid, $tid);
- my $sender = $get_real_sender->($ref);
- my $username = $ref->{pmail};
-
- if ($action eq 'whitelist') {
- PMG::Quarantine::add_to_blackwhite($dbh, $username, 'WL', [ $sender ]);
- } elsif ($action eq 'blacklist') {
- PMG::Quarantine::add_to_blackwhite($dbh, $username, 'BL', [ $sender ]);
- } elsif ($action eq 'deliver') {
- PMG::Quarantine::deliver_quarantined_mail($dbh, $ref, $pmail);
- } elsif ($action eq 'delete') {
- PMG::Quarantine::delete_quarantined_mail($dbh, $ref, $pmail);
- } else {
- die "internal error"; # should not be reached
+ if ($role eq 'quser') {
+ my $quar_username = $ref->{pmail} . '@quarantine';
+ raise_perm_exc("mail does not belong to user '$authuser' ($ref->{pmail})")
+ if $authuser ne $quar_username;
+ }
+
+ my $sender = $get_real_sender->($ref);
+
+ if ($action eq 'whitelist') {
+ PMG::Quarantine::add_to_blackwhite($dbh, $ref->{pmail}, 'WL', [ $sender ]);
+ } elsif ($action eq 'blacklist') {
+ PMG::Quarantine::add_to_blackwhite($dbh, $ref->{pmail}, 'BL', [ $sender ]);
+ } elsif ($action eq 'deliver') {
+ PMG::Quarantine::deliver_quarantined_mail($dbh, $ref, $ref->{receiver} // $ref->{pmail});
+ } elsif ($action eq 'delete') {
+ PMG::Quarantine::delete_quarantined_mail($dbh, $ref);
+ } else {
+ die "internal error"; # should not be reached
+ }
}
return undef;