X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FWatchMaildir.pm;h=02e4b32f254a8933e81e60b2001b8cc5ebce63c8;hb=e5a139171c3d9bfa23c4da009839cd6eafe3dae1;hp=cf1dfa7656704bc3dcdeb637dd4a6e522a1fd4b3;hpb=ab2b0607f05904866784684603c4a1f5c13c1e80;p=public-inbox.git diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm index cf1dfa76..02e4b32f 100644 --- a/lib/PublicInbox/WatchMaildir.pm +++ b/lib/PublicInbox/WatchMaildir.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2019 all contributors +# Copyright (C) 2016-2020 all contributors # License: AGPL-3.0+ # # ref: https://cr.yp.to/proto/maildir.html @@ -11,7 +11,7 @@ use PublicInbox::InboxWritable; use File::Temp 0.19 (); # 0.19 for ->newdir use PublicInbox::Filter::Base qw(REJECT); use PublicInbox::Spamcheck; -*maildir_path_load = *PublicInbox::InboxWritable::maildir_path_load; +*mime_from_path = \&PublicInbox::InboxWritable::mime_from_path; sub new { my ($class, $config) = @_; @@ -59,9 +59,11 @@ sub new { my $watch = $ibx->{watch} or return; if (is_maildir($watch)) { my $watch_hdrs = []; - if (my $wh = $ibx->{watchheader}) { - my ($k, $v) = split(/:/, $wh, 2); - push @$watch_hdrs, [ $k, qr/\Q$v\E/ ]; + if (my $whs = $ibx->{watchheader}) { + for (@$whs) { + my ($k, $v) = split(/:/, $_, 2); + push @$watch_hdrs, [ $k, qr/\Q$v\E/ ]; + } } if (my $list_ids = $ibx->{listid}) { for (@$list_ids) { @@ -123,7 +125,7 @@ sub _remove_spam { my ($self, $path) = @_; # path must be marked as (S)een $path =~ /:2,[A-R]*S[T-Za-z]*\z/ or return; - my $mime = maildir_path_load($path) or return; + my $mime = mime_from_path($path) or return; $self->{config}->each_inbox(sub { my ($ibx) = @_; eval { @@ -165,7 +167,7 @@ sub _try_path { $warn_cb->(@_); }; foreach my $ibx (@$inboxes) { - my $mime = maildir_path_load($path) or next; + my $mime = mime_from_path($path) or next; my $im = _importer_for($self, $ibx); # any header match means it's eligible for the inbox: @@ -173,10 +175,8 @@ sub _try_path { my $ok; my $hdr = $mime->header_obj; for my $wh (@$watch_hdrs) { - my $v = $hdr->header_raw($wh->[0]); - next unless defined($v) && $v =~ $wh->[1]; - $ok = 1; - last; + my @v = $hdr->header_raw($wh->[0]); + $ok = grep(/$wh->[1]/, @v) and last; } next unless $ok; }