X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=scripts%2Fimport_slrnspool;h=1dccb8dd51c10793f06eca441eaf02156e15f427;hb=4821798351defce82c102e46d6f5f84f0cdc0e34;hp=1a7d77a4d767d5d69f5e9a1b341dffa2841e7e56;hpb=8d562ac834d69e18030cb2969a827b121aa4324a;p=public-inbox.git diff --git a/scripts/import_slrnspool b/scripts/import_slrnspool index 1a7d77a4..1dccb8dd 100755 --- a/scripts/import_slrnspool +++ b/scripts/import_slrnspool @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# Copyright (C) 2015-2018 all contributors +# Copyright (C) 2015-2019 all contributors # License: AGPL-3.0+ # # Incremental (or one-shot) importer of a slrnpull news spool @@ -35,6 +35,9 @@ if (($ibx->{version} || 1) == 2) { $ibx->{-primary_address}); } +$ibx->{filter} ||= 'PublicInbox::Filter::Gmane'; +my $filter = $ibx->filter; + sub key { "publicinbox.$ibx->{name}.importslrnspoolstate"; } @@ -44,7 +47,7 @@ sub get_min { my $out = $git->qx('config', "--file=$f", key($ibx)); $out ||= 0; chomp $out; - $out =~ /\A\d+\z/ and return $out; + $out =~ /\A[0-9]+\z/ and return $out; 0; } @@ -68,26 +71,7 @@ for (; $exit == 0 && $n < $max; $n++) { print STDERR $fn, "\n"; my $mime = PublicInbox::MIME->new(eval { local $/; <$fh> }); - my $hdr = $mime->header_obj; - - # gmane rewrites Received headers, which increases spamminess - # Some older archives set Original-To - foreach my $x (qw(Received To)) { - my @h = $hdr->header_raw("Original-$x"); - if (@h) { - $hdr->header_set($x, @h); - $hdr->header_set("Original-$x"); - } - } - - # Approved triggers for the SA HEADER_SPAM rule, - # X-From is gmane specific - foreach my $drop (qw(Approved X-From)) { - $hdr->header_set($drop); - } - - # appears to be an old gmane bug: - $hdr->header_set('connect()'); + $filter->scrub($mime); $im->add($mime); $ok = $n + 1;