the disclaimer action currently does not log, if a disclaimer got added or not.
given that there are a few not directly obvious cases where a disclaimer does
not get added (e.g. it depends on the mail's encoding) - logging success or
failure should help in debugging
Tested by sending mails, where adding the disclaimer works, and where it fails.
verified that the log-tracker also adds those lines to its output.
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
use IO::File;
use Encode qw(decode encode);
use IO::File;
use Encode qw(decode encode);
use PMG::Utils;
use PMG::ModGroup;
use PMG::RuleDB::Object;;
use PMG::Utils;
use PMG::ModGroup;
use PMG::RuleDB::Object;;
- my ($self, $entity, $html, $text) = @_;
+ my ($self, $entity, $html, $text, $logid, $rulename) = @_;
my $found = 0;
if ($entity->head->mime_type =~ m{multipart/alternative}) {
foreach my $p ($entity->parts) {
my $found = 0;
if ($entity->head->mime_type =~ m{multipart/alternative}) {
foreach my $p ($entity->parts) {
- $found = 1 if $self->sign ($p, $html, $text);
+ $found = 1 if $self->sign ($p, $html, $text, $logid, $rulename);
}
} elsif ($entity->head->mime_type =~ m{multipart/}) {
foreach my $p ($entity->parts) {
}
} elsif ($entity->head->mime_type =~ m{multipart/}) {
foreach my $p ($entity->parts) {
- if ($self->sign ($p, $html, $text)) {
+ if ($self->sign ($p, $html, $text, $logid, $rulename)) {
};
# simply ignore if we can't represent the disclainer
# with that encoding
};
# simply ignore if we can't represent the disclainer
# with that encoding
+ if ($@) {
+ syslog('info', "%s: adding disclaimer failed (rule: %s)", $logid, $rulename);
+ } else {
+ syslog('info', "%s: added disclaimer (rule: %s)", $logid, $rulename);
+ }
$found = 1;
} else {
# do nothing - unknown format
$found = 1;
} else {
# do nothing - unknown format
my ($self, $queue, $ruledb, $mod_group, $targets,
$msginfo, $vars, $marks) = @_;
my ($self, $queue, $ruledb, $mod_group, $targets,
$msginfo, $vars, $marks) = @_;
+ my $rulename = $vars->{RULE} // 'unknown';
+
my $subgroups = $mod_group->subgroups($targets);
foreach my $ta (@$subgroups) {
my $subgroups = $mod_group->subgroups($targets);
foreach my $ta (@$subgroups) {
$parser->parse($tmp);
$parser->eof;
$parser->parse($tmp);
$parser->eof;
- $self->sign($entity, "$html\n", "$text\n");
+ $self->sign($entity, "$html\n", "$text\n", $queue->{logid}, $rulename);