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. --- public-inbox-learn | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'public-inbox-learn') diff --git a/public-inbox-learn b/public-inbox-learn index d770f0f7..2c2bbfb5 100755 --- a/public-inbox-learn +++ b/public-inbox-learn @@ -54,19 +54,22 @@ foreach my $recipient (keys %dests) { } } } else { # $train eq "ham" - my $from = $simple->header("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 = ""; + require PublicInbox::MDA; + require PublicInbox::Filter; + + # no checking for errors here, we assume the message has + # been reviewed by a human at this point: + PublicInbox::Filter->run($simple); + + my ($name, $email, $date) = + PublicInbox::MDA->author_info($simple); local $ENV{GIT_AUTHOR_NAME} = $name; local $ENV{GIT_AUTHOR_EMAIL} = $email; - local $ENV{GIT_AUTHOR_DATE} = $simple->header("Date"); + local $ENV{GIT_AUTHOR_DATE} = $date; # Ham messages are trained when they're marked into - # a SEEN state, so this is idempotent - run([qw(ssoma-mda -1), $git_dir], \$in, \$out, \$err); + # a SEEN state, so this is idempotent: + run([PublicInbox::MDA->cmd, $git_dir], \$in, \$out, \$err); if ($err !~ /CONFLICT/) { $err = 1; } -- cgit v1.2.3-24-ge0c7