From 0718a13ba8225c9d180b3207470876d048184310 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Sun, 12 Jun 2022 15:11:28 -0400 Subject: Allow flagging infinite sends by setting remaing count to -1. --- lib/SpamCat.pm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'lib') 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 = ?"; } -- cgit v1.2.3