X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=script%2Fpublic-inbox-learn;h=0d6c989b8ee00be88449d128f2e890239154d034;hb=2fc67a18b7ccd75ea6eb945f18203cbf4bcf228f;hp=79f3ead5c722cda3d17cea9f4fc8ea185fa39530;hpb=d1525c3b35e9aa1bb14143996a7fa2b6e34cba3e;p=public-inbox.git diff --git a/script/public-inbox-learn b/script/public-inbox-learn index 79f3ead5..0d6c989b 100644 --- a/script/public-inbox-learn +++ b/script/public-inbox-learn @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# Copyright (C) 2014-2019 all contributors +# Copyright (C) 2014-2020 all contributors # License: AGPL-3.0+ # # Used for training spam (via SpamAssassin) and removing messages from a @@ -39,8 +39,8 @@ my $mime = PublicInbox::MIME->new(eval { $data }); -sub remove_or_add ($$$) { - my ($ibx, $train, $addr) = @_; +sub remove_or_add ($$$$) { + my ($ibx, $train, $mime, $addr) = @_; # We do not touch GIT_COMMITTER_* env here so we can track # who trained the message. @@ -93,11 +93,12 @@ if ($train eq 'spam') { while (my ($addr, $ibx) = each %dests) { next unless ref($ibx); # $ibx may be 0 next if $seen{"$ibx"}++; - remove_or_add($ibx, $train, $addr); + remove_or_add($ibx, $train, $mime, $addr); } - my $ibx = PublicInbox::MDA->inbox_for_list_id($pi_config, $mime); - if ($ibx && !$seen{"$ibx"}) { - remove_or_add($ibx, $train, $ibx->{-primary_address}); + my $dests = PublicInbox::MDA->inboxes_for_list_id($pi_config, $mime); + for my $ibx (@$dests) { + next if !$seen{"$ibx"}++; + remove_or_add($ibx, $train, $mime, $ibx->{-primary_address}); } }