about summary refs log tree commit homepage
path: root/lib/PublicInbox/Filter/Gmane.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2018-12-28 19:17:36 +0000
committerEric Wong <e@80x24.org>2018-12-28 19:24:06 +0000
commit7715c70e5a8667fbd9eade0cffb6ab05a714dd5d (patch)
tree1518de184d01cc586b857c1e666d0d7cd648f468 /lib/PublicInbox/Filter/Gmane.pm
parent0e933ed9b8a751d70623f72fbee98ad77af7578c (diff)
downloadpublic-inbox-7715c70e5a8667fbd9eade0cffb6ab05a714dd5d.tar.gz
Extracted from import_slrnspool, since some spools get converted
to mbox or what not.
Diffstat (limited to 'lib/PublicInbox/Filter/Gmane.pm')
-rw-r--r--lib/PublicInbox/Filter/Gmane.pm41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/PublicInbox/Filter/Gmane.pm b/lib/PublicInbox/Filter/Gmane.pm
new file mode 100644
index 00000000..f9042dfc
--- /dev/null
+++ b/lib/PublicInbox/Filter/Gmane.pm
@@ -0,0 +1,41 @@
+# Copyright (C) 2018 all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+
+# Filter for importing some archives from gmane
+package PublicInbox::Filter::Gmane;
+use base qw(PublicInbox::Filter::Base);
+use strict;
+use warnings;
+
+sub scrub {
+        my ($self, $mime) = @_;
+        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()');
+
+        $self->ACCEPT($mime);
+}
+
+sub delivery {
+        my ($self, $mime) = @_;
+        $self->scrub($mime);
+}
+
+1;