use strict;
use warnings;
use PublicInbox::MIME;
-use PublicInbox::Git;
-use PublicInbox::Import;
-use PublicInbox::MDA;
use PublicInbox::Spawn qw(spawn);
use PublicInbox::InboxWritable;
use File::Temp qw//;
foreach my $pfx (qw(publicinboxwatch publicinboxlearn)) {
my $k = "$pfx.watchspam";
if (my $dir = $config->{$k}) {
- if ($dir =~ s/\Amaildir://) {
- $dir =~ s!/+\z!!;
+ if (is_maildir($dir)) {
# skip "new", no MUA has seen it, yet.
my $cur = "$dir/cur";
my $old = $mdmap{$cur};
my $ibx = $_[0] = PublicInbox::InboxWritable->new($_[0]);
my $watch = $ibx->{watch} or return;
- if ($watch =~ s/\Amaildir://) {
- $watch =~ s!/+\z!!;
+ if (is_maildir($watch)) {
if (my $wm = $ibx->{watchheader}) {
my ($k, $v) = split(/:/, $wm, 2);
$ibx->{-watchheader} = [ $k, qr/\Q$v\E/ ];
eval {
my $im = _importer_for($self, $ibx);
$im->remove($mime, 'spam');
- if (my $scrub = $ibx->filter) {
+ if (my $scrub = $ibx->filter($im)) {
my $scrubbed = $scrub->scrub($mime, 1);
$scrubbed or return;
$scrubbed == REJECT() and return;
if (!ref($inboxes) && $inboxes eq 'watchspam') {
return _remove_spam($self, $path);
}
+
+ my $warn_cb = $SIG{__WARN__} || sub { print STDERR @_ };
+ local $SIG{__WARN__} = sub {
+ $warn_cb->("path: $path\n");
+ $warn_cb->(@_);
+ };
foreach my $ibx (@$inboxes) {
my $mime = _path_to_mime($path) or next;
my $im = _importer_for($self, $ibx);
my $v = $mime->header_obj->header_raw($wm->[0]);
next unless ($v && $v =~ $wm->[1]);
}
- if (my $scrub = $ibx->filter) {
+
+ if (my $scrub = $ibx->filter($im)) {
my $ret = $scrub->scrub($mime) or next;
$ret == REJECT() and next;
$mime = $ret;
}
}
+sub is_maildir {
+ $_[0] =~ s!\Amaildir:!! or return;
+ $_[0] =~ tr!/!/!s;
+ $_[0] =~ s!/\z!!;
+ $_[0];
+}
+
1;