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/
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);
}
}
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];
}
});
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);
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');
}