- my (%mdmap, @mdir);
- my $k = 'publicinboxlearn.watchspam';
- if (my $spamdir = $config->{$k}) {
- if ($spamdir =~ s/\Amaildir://) {
- $spamdir =~ s!/+\z!!;
- # skip "new", no MUA has seen it, yet.
- my $cur = "$spamdir/cur";
- push @mdir, $cur;
- $mdmap{$cur} = 'watchspam';
- } else {
- warn "unsupported $k=$spamdir\n";
+ my (%mdmap, @mdir, $spamc);
+ my %uniq;
+
+ # "publicinboxwatch" is the documented namespace
+ # "publicinboxlearn" is legacy but may be supported
+ # indefinitely...
+ foreach my $pfx (qw(publicinboxwatch publicinboxlearn)) {
+ my $k = "$pfx.watchspam";
+ defined(my $dirs = $config->{$k}) or next;
+ $dirs = [ $dirs ] if !ref($dirs);
+ for my $dir (@$dirs) {
+ if (is_maildir($dir)) {
+ # skip "new", no MUA has seen it, yet.
+ my $cur = "$dir/cur";
+ my $old = $mdmap{$cur};
+ if (ref($old)) {
+ foreach my $ibx (@$old) {
+ warn <<"";
+"$cur already watched for `$ibx->{name}'
+
+ }
+ die;
+ }
+ push @mdir, $cur;
+ $uniq{$cur}++;
+ $mdmap{$cur} = 'watchspam';
+ } else {
+ warn "unsupported $k=$dir\n";
+ }