From a8d9e2f1853032016db6ff177979873b3bdadd85 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 19 Apr 2014 23:23:10 +0000 Subject: mda: share commit setup code with -learn We need -learn to do many of the same things as -mda when we have a false-positive. We also need -learn to do HTML filtering in case the training user screws up. --- lib/PublicInbox/MDA.pm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'lib') diff --git a/lib/PublicInbox/MDA.pm b/lib/PublicInbox/MDA.pm index 22879236..bb14ae50 100644 --- a/lib/PublicInbox/MDA.pm +++ b/lib/PublicInbox/MDA.pm @@ -4,8 +4,10 @@ package PublicInbox::MDA; use strict; use warnings; use Email::Address; +use Encode qw/decode encode/; use Date::Parse qw(strptime); use constant MAX_SIZE => 1024 * 500; # same as spamc default +use constant cmd => qw/ssoma-mda -1/; # drop plus addressing for matching sub __drop_plus { @@ -53,4 +55,32 @@ sub recipient_specified { return 0; } +# RFC2919 and RFC2369 +sub set_list_headers { + my ($class, $simple, $dst) = @_; + my $pa = "<$dst->{-primary_address}>"; + $simple->header_set("List-Id", $pa); + $simple->header_set("List-Post", $pa); + + my $url = $dst->{url}; + if (defined $url) { + $simple->header_set("List-Archive", "<$url>"); + $simple->header_set("List-Help", "<${url}help>"); + } +} + +# returns a 3-element array: name, email, date +sub author_info { + my ($class, $simple) = @_; + + my $from = decode('MIME-Header', $simple->header('From')); + $from = encode('utf8', $from); + my @from = Email::Address->parse($from); + my $name = $from[0]->name; + defined $name or $name = ''; + my $email = $from[0]->address; + defined $email or $email = ''; + ($name, $email, $simple->header('Date')); +} + 1; -- cgit v1.2.3-24-ge0c7