aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2022-06-12 15:11:28 -0400
committerBrian Cully <bjc@kublai.com>2022-06-12 15:13:34 -0400
commit0718a13ba8225c9d180b3207470876d048184310 (patch)
tree33a2080eac997e8304d729d6743ff98103e6eed2 /lib
parent575c0485c4939922bab313da666a8a18d80c065e (diff)
downloadspamcat-0718a13ba8225c9d180b3207470876d048184310.tar.gz
spamcat-0718a13ba8225c9d180b3207470876d048184310.zip
Allow flagging infinite sends by setting remaing count to -1.
Diffstat (limited to 'lib')
-rw-r--r--lib/SpamCat.pm20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/SpamCat.pm b/lib/SpamCat.pm
index 0f3c8b8..7dff474 100644
--- a/lib/SpamCat.pm
+++ b/lib/SpamCat.pm
@@ -47,15 +47,17 @@ sub deliver {
if (defined $count) {
return if $count == 0;
- my $count_str = '[' . $count . '/' . $self->{default_count} . ']';
- my $new_subject = $email->header('Subject');
- if ($new_subject) {
- $new_subject .= ' - ' . $count_str;
- } else {
- $new_subject = $count_str;
+ if ($count > 0) {
+ my $count_str = '[' . $count . '/' . $self->{default_count} . ']';
+ my $new_subject = $email->header('Subject');
+ if ($new_subject) {
+ $new_subject .= ' - ' . $count_str;
+ } else {
+ $new_subject = $count_str;
+ }
+ $email->header_set('Subject' => $new_subject);
+ $email->header_set('X-SpamCat-Remaining' => $count);
}
- $email->header_set('Subject' => $new_subject);
- $email->header_set('X-SpamCat-Remaining' => $count);
}
my $deliverfh = IO::File->new("| " . $self->{deliver}) ||
@@ -163,7 +165,7 @@ sub decrement_count_t {
$count = $self->{default_count};
$q = 'INSERT INTO emails (count, sender) VALUES (?, ?)';
} else {
- $count = $count <= 0 ? '0' : $count - 1;
+ $count = $count <= 0 ? $count : $count - 1;
$q = "UPDATE emails SET count = ?, modified = CURRENT_TIMESTAMP WHERE sender = ?";
}