diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/SpamCat.pm | 20 |
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 = ?"; } |