]> Sergey Matveev's repositories - public-inbox.git/blobdiff - public-inbox-mda
mda: add most RFC 2919 and 2369 headers
[public-inbox.git] / public-inbox-mda
index 14017f68d265cf4fc4c9bde3864136f61dc18d49..6e66fa71da63c56ccfcf3cfea5390696ae01e117 100755 (executable)
@@ -42,6 +42,7 @@ if (PublicInbox->precheck($filter, $recipient) &&
                # run spamc again on the HTML-free message
                if (do_spamc($simple, \$filtered)) {
                        $simple = Email::Simple->new($filtered);
+                       set_list_headers($simple, $dst);
                        $filter->simple($simple);
 
                        my $from = $filter->from;
@@ -52,6 +53,7 @@ if (PublicInbox->precheck($filter, $recipient) &&
                        defined $email or $email = "";
                        local $ENV{GIT_AUTHOR_NAME} = $name;
                        local $ENV{GIT_AUTHOR_EMAIL} = $email;
+                       local $ENV{GIT_AUTHOR_DATE} = $simple->header("Date");
                        local $ENV{GIT_COMMITTER_EMAIL} = $recipient;
                        local $ENV{GIT_COMMITTER_NAME} = $dst->{listname};
 
@@ -73,3 +75,17 @@ sub do_spamc {
 
        return ($@ || $? || !defined($$out) || length($$out) == 0) ? 0 : 1;
 }
+
+# RFC2919 and RFC2369
+sub set_list_headers {
+       my ($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>");
+       }
+}