]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/Filter/Gmane.pm
treewide: run update-copyrights from gnulib for 2019
[public-inbox.git] / lib / PublicInbox / Filter / Gmane.pm
1 # Copyright (C) 2018-2020 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3
4 # Filter for importing some archives from gmane
5 package PublicInbox::Filter::Gmane;
6 use base qw(PublicInbox::Filter::Base);
7 use strict;
8 use warnings;
9
10 sub scrub {
11         my ($self, $mime) = @_;
12         my $hdr = $mime->header_obj;
13
14         # gmane rewrites Received headers, which increases spamminess
15         # Some older archives set Original-To
16         foreach my $x (qw(Received To)) {
17                 my @h = $hdr->header_raw("Original-$x");
18                 if (@h) {
19                         $hdr->header_set($x, @h);
20                         $hdr->header_set("Original-$x");
21                 }
22         }
23
24         # Approved triggers for the SA HEADER_SPAM rule,
25         # X-From is gmane specific
26         foreach my $drop (qw(Approved X-From)) {
27                 $hdr->header_set($drop);
28         }
29
30         # appears to be an old gmane bug:
31         $hdr->header_set('connect()');
32
33         $self->ACCEPT($mime);
34 }
35
36 sub delivery {
37         my ($self, $mime) = @_;
38         $self->scrub($mime);
39 }
40
41 1;