about summary refs log tree commit homepage
path: root/public-inbox-learn
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2014-04-19 23:23:10 +0000
committerEric Wong <e@80x24.org>2014-04-19 23:27:18 +0000
commita8d9e2f1853032016db6ff177979873b3bdadd85 (patch)
tree8f76f5c29c205412d843f3c58ebccc9c74cdc936 /public-inbox-learn
parent4024aae69fe08c0aa14a69a12d55ca2b7dd4a4ab (diff)
downloadpublic-inbox-a8d9e2f1853032016db6ff177979873b3bdadd85.tar.gz
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.
Diffstat (limited to 'public-inbox-learn')
-rwxr-xr-xpublic-inbox-learn21
1 files changed, 12 insertions, 9 deletions
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;
                 }