about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-27 10:03:50 +0000
committerEric Wong <e@yhbt.net>2020-06-28 22:27:26 +0000
commit62e3ea11522242c651ea4991712f040ab460223d (patch)
tree4d172f995ab21841bd29e10cfea40c2cbf0a648a
parent5f03b6c95af21dc2d499618ba03d63c44f70828c (diff)
downloadpublic-inbox-62e3ea11522242c651ea4991712f040ab460223d.tar.gz
Some users will find it useful to merge several Maildir or
IMAP mailboxes into one public-inbox.  Let them do it, since
we've always supported multi-address inboxes.
-rw-r--r--lib/PublicInbox/WatchMaildir.pm36
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm
index e4106490..621d41bd 100644
--- a/lib/PublicInbox/WatchMaildir.pm
+++ b/lib/PublicInbox/WatchMaildir.pm
@@ -50,7 +50,7 @@ sub new {
         foreach my $pfx (qw(publicinboxwatch publicinboxlearn)) {
                 my $k = "$pfx.watchspam";
                 defined(my $dirs = $config->{$k}) or next;
-                $dirs = [ $dirs ] if !ref($dirs);
+                $dirs = PublicInbox::Config::_array($dirs);
                 for my $dir (@$dirs) {
                         if (is_maildir($dir)) {
                                 # skip "new", no MUA has seen it, yet.
@@ -75,21 +75,25 @@ sub new {
                 # need to make all inboxes writable for spam removal:
                 my $ibx = $_[0] = PublicInbox::InboxWritable->new($_[0]);
 
-                my $watch = $ibx->{watch} or return;
-                if (is_maildir($watch)) {
-                        compile_watchheaders($ibx);
-                        my ($new, $cur) = ("$watch/new", "$watch/cur");
-                        return if is_watchspam($cur, $mdmap{$cur}, $ibx);
-                        push @mdir, $new unless $uniq{$new}++;
-                        push @mdir, $cur unless $uniq{$cur}++;
-                        push @{$mdmap{$new} ||= []}, $ibx;
-                        push @{$mdmap{$cur} ||= []}, $ibx;
-                } elsif (my $url = imap_url($watch)) {
-                        return if is_watchspam($url, $imap{$url}, $ibx);
-                        compile_watchheaders($ibx);
-                        push @{$imap{$url} ||= []}, $ibx;
-                } else {
-                        warn "watch unsupported: $k=$watch\n";
+                my $watches = $ibx->{watch} or return;
+                $watches = PublicInbox::Config::_array($watches);
+                for my $watch (@$watches) {
+                        if (is_maildir($watch)) {
+                                compile_watchheaders($ibx);
+                                my ($new, $cur) = ("$watch/new", "$watch/cur");
+                                my $cur_dst = $mdmap{$cur} //= [];
+                                return if is_watchspam($cur, $cur_dst, $ibx);
+                                push @mdir, $new unless $uniq{$new}++;
+                                push @mdir, $cur unless $uniq{$cur}++;
+                                push @{$mdmap{$new} //= []}, $ibx;
+                                push @$cur_dst, $ibx;
+                        } elsif (my $url = imap_url($watch)) {
+                                return if is_watchspam($url, $imap{$url}, $ibx);
+                                compile_watchheaders($ibx);
+                                push @{$imap{$url} ||= []}, $ibx;
+                        } else {
+                                warn "watch unsupported: $k=$watch\n";
+                        }
                 }
         });
         return unless scalar(@mdir) || scalar(keys %imap);