]> www.infradead.org Git - users/dedekind/aiaiai.git/commitdiff
email-lda: improve consistency and readability
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Wed, 5 Feb 2014 14:20:13 +0000 (16:20 +0200)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Wed, 5 Feb 2014 15:12:12 +0000 (17:12 +0200)
Similarly to what we did in 'aiaiai-email-test-patchset', use 'reply_*'
variable to specify the reply recipient, the Cc list, the subject, and the
message ID. This is a bit easier to read and consistent.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
email/aiaiai-email-lda

index 83a687b18558c0766278897899286b6c72ca55d2..336bd09d4054c4da9a090cd63868b53b6c4dbcc6 100755 (executable)
@@ -69,9 +69,7 @@ reject()
 {
        local file="$1"; shift
        local reason="$1" shift
-       local subj
-       local from
-       local id
+       local subj from id
 
        fetch_header_or_die subj "Subject" < "$file"
        fetch_header_or_die from "From" < "$file"
@@ -85,32 +83,31 @@ reject()
 reject_and_reply()
 {
        local file="$1"; shift
-       local subj
-       local from
-       local id
-       local to
-       local cc
+       local reply_to reply_cc reply_id reply_subj to cc
 
-       fetch_header_or_die subj "Subject" < "$file"
-       fetch_header_or_die from "From" < "$file"
-       fetch_header_or_die id "Message-Id" < "$file"
+       fetch_header_or_die reply_to "From" < "$file"
+       fetch_header_or_die reply_subj "Subject" < "$file"
+       fetch_header_or_die reply_id "Message-Id" < "$file"
 
        to="$(fetch_header "To" < "$mbox")"
        cc="$(fetch_header "Cc" < "$mbox")"
-       to="$(merge_addresses "$to" "$cc")"
 
-       prj="$(fetch_project_name "$to" "$cfg_ownmail")"
+       reply_cc="$(merge_addresses "$to" "$cc")"
+
+       prj="$(fetch_project_name "$reply_cc" "$cfg_ownmail")"
        verbose "Project \"$prj\""
        parse_prj_config "$cfgfile" "$prj"
 
        if [ -n "$pcfg_name" ] && [ "$pcfg_reply_to_all" = "1" ]; then
                # Strip own address
-               to=$(strip_address "$to" "$cfg_ownmail")
+               reply_cc="$(merge_addresses "$reply_cc" "$pcfg_always_cc")"
+               reply_cc=$(strip_address "$reply_cc" "$cfg_ownmail")
        else
-               to=
+               reply_cc=
        fi
 
-       compose_email "$from" "$to" "$subj" "$id" > "$lda_tmp/mail"
+       compose_email "$reply_to" "$reply_cc" "$reply_subj" "$reply_id" \
+               > "$lda_tmp/mail"
 
        [ -z "$verbose" ] || cat -- "$lda_tmp/mail" >&2