From: Robert Jarzmik Date: Thu, 6 Nov 2014 18:50:28 +0000 (+0100) Subject: aiaiai-email-lda: use the References mail header X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=cbce25df314f4245916fe3c48505fa005521f0db;p=users%2Fdedekind%2Faiaiai.git aiaiai-email-lda: use the References mail header Aiaiai local mail delivery agent should be able to cope with forwarded mails, not only git-send-email. One popular method of forwarding a mail thread is to have it embedded in a single mulitpart mail in rfc822 format. But this transformation changes the In-Reply-To: headers into References: headers. The goal of this patch is to teach aiaiai LDA to understand both In-Reply-To and References in its mail handling. This enables mail forwarding. Jacob: Fix up variable quotes in the README example. Fix up style for mail headers, and fix a typo. Signed-off-by: Robert Jarzmik Signed-off-by: Jacob Keller --- diff --git a/doc/README b/doc/README index dbc2547..9ec1254 100644 --- a/doc/README +++ b/doc/README @@ -102,6 +102,28 @@ The 'aiaiai-test-patchset' script does all the testing work and outputs the test results to stdout. 'aiaiai-email-test-patchset' captures the output and sends it back to the patch submitter. +A more complicated mail setup dealing with forwards and multi-part emails +would be : +$ cat /home/aiaiai/bin/my-aiaiai-lda + #!/bin/sh + formail_opt="" + + mail=$(mktemp) + cat > $mail + + to="$(formail -c -z -x "To:" < $mail)" + [ -n "$to" ] && formail_opt="$formail_opt -I \"To: $to\"" + + project="$(formail -c -z -x "X-Aiaiai-Project:" < $mail)" + [ -n "$project" ] && formail_opt="$formail_opt -I \"X-Aiaiai-Project: $project\"" + + commit="$(formail -c -z -x "X-Aiaiai-Commit:" < $mail)" + [ -n "$commit" ] && formail_opt="$formail_opt -I \"X-Aiaiai-Commit: $commit\"" + + cat "$mail" | eval formail $formail_opt -d -s "$HOME/git/email/aiaiai-email-lda" \ + -v --reap-archive=43200 --reap-incomplete=10 -- "$HOME/aiaiai-workdir" \ + >> "$HOME/aiaiai-logs/email-lda.log" 2>&1 + 1.2 Email Configuration ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/email/aiaiai-email-lda b/email/aiaiai-email-lda index 365d7cf..4927dd1 100755 --- a/email/aiaiai-email-lda +++ b/email/aiaiai-email-lda @@ -157,10 +157,10 @@ find_relatives() local parent_id="$1"; shift # Find the parent, children, and brothers - LC_ALL=C grep -i -l -r -- "In-Reply-To: $id" "$where" ||: + LC_ALL=C grep -i -l -r -- "\(In-Reply-To\|References\): $id" "$where" ||: if [ -n "$parent_id" ]; then LC_ALL=C grep -i -l -r -- "Message-Id: $parent_id" "$where" ||: - LC_ALL=C grep -i -l -r -- "In-Reply-To: $parent_id" "$where" ||: + LC_ALL=C grep -i -l -r -- "\(In-Reply-To\|References\): $parent_id" "$where" ||: fi } @@ -173,6 +173,7 @@ series_is_complete() local cnt="$(ls -1 --ignore=0 -- "$dir" | wc -l)" if [ "$cnt" -eq "$n" ]; then local first_parent="$(fetch_header "In-Reply-To" < "$dir/1")" + [ -z "$first_parent" ] && first_parent="$(fetch_header "References" < "$dir/1")" if [ -n "$first_parent" ]; then # The first patch has a parent, must be the cover letter if [ -f "$dir/0" ]; then @@ -256,9 +257,9 @@ move_to_series() # try to collect all patches belonging to the series, and when it receives the # last patch, it queues the entire series. # -# The series is collected using message ID headers - each patch, except of may -# be the first one, must refer the previous patches ID via teh "In-Reply-To" -# header. +# The series is collected using message ID headers - each patch, except for the +# first one, must refer the previous patches ID via the "In-Reply-To:" header +# or "References:" header. process_series_mbox() { local mbox="$1"; shift @@ -269,12 +270,15 @@ process_series_mbox() # Only patch 0/n or 1/n is allowed to have no parent local parent_id="$(fetch_header "In-Reply-To" < "$mbox")" + [ -z "$parent_id" ] && parent_id="$(fetch_header "References" < "$mbox")" + if [ -z "$parent_id" ] && [ "$m" != 1 ] && [ "$m" != 0 ]; then reject_and_reply "$mbox" <