]> Sergey Matveev's repositories - public-inbox.git/commitdiff
filter/rubylang: do not set altid on spam training
authorEric Wong <e@80x24.org>
Thu, 19 Apr 2018 22:42:05 +0000 (22:42 +0000)
committerEric Wong <e@80x24.org>
Thu, 19 Apr 2018 22:43:03 +0000 (22:43 +0000)
I suppose it's a bug or inconsistency that altid is write-only
and their deletions do not get reflected.  But for now, we
do not set it when training spam so there's no window where
an invalid NNTP article number shows up.

This should solve the problem where there's massive gaps
in messages solved by spam training for ruby groups:

https://public-inbox.org/meta/20180307093754.GA27748@dcvr/

lib/PublicInbox/Filter/Base.pm
lib/PublicInbox/Filter/RubyLang.pm
lib/PublicInbox/WatchMaildir.pm

index 5d070132a4101c78408018283eb8734247806974..638b627af5d4370221a07b1c167a5883f62d235d 100644 (file)
@@ -66,9 +66,10 @@ sub reject ($$) {
 sub err ($) { $_[0]->{err} }
 
 # by default, scrub is a no-op, see PublicInbox::Filter::Vger::scrub
-# for an example of the override
+# for an example of the override.  The $for_remove arg is set to
+# disable altid setting for spam removal.
 sub scrub {
-       my ($self, $mime) = @_;
+       my ($self, $mime, $for_remove) = @_;
        $self->ACCEPT($mime);
 }
 
index cb69e38a68aa01891287edd8b53448e53cd36259..a43d67a9352e4ea6ab71aad954b3fe44933d55e3 100644 (file)
@@ -30,7 +30,7 @@ sub new {
 }
 
 sub scrub {
-       my ($self, $mime) = @_;
+       my ($self, $mime, $for_remove) = @_;
        # no msg_iter here, that is only for read-only access
        $mime->walk_parts(sub {
                my ($part) = $_[0];
@@ -43,7 +43,7 @@ sub scrub {
                }
        });
        my $altid = $self->{-altid};
-       if ($altid) {
+       if ($altid && !$for_remove) {
                my $hdr = $mime->header_obj;
                my $mids = mids($hdr);
                return $self->REJECT('Message-ID missing') unless (@$mids);
index 7ee29da54ebd5cf27f16ba32b2654fed87831df8..10dc618416a377387652f1ebab198be4bb91f60b 100644 (file)
@@ -126,7 +126,8 @@ sub _remove_spam {
                        my $im = _importer_for($self, $ibx);
                        $im->remove($mime, 'spam');
                        if (my $scrub = $ibx->filter) {
-                               my $scrubbed = $scrub->scrub($mime) or return;
+                               my $scrubbed = $scrub->scrub($mime, 1);
+                               $scrubbed or return;
                                $scrubbed == REJECT() and return;
                                $im->remove($scrubbed, 'spam');
                        }