]> git.notmuchmail.org Git - notmuch/commitdiff
reply: Include sender as recipient if they were the original recipient
authorDavid Edmondson <dme@dme.org>
Mon, 1 Oct 2018 16:50:47 +0000 (17:50 +0100)
committerDavid Bremner <david@tethera.net>
Fri, 7 Dec 2018 12:03:50 +0000 (08:03 -0400)
When generating a reply message, if the user was the originator and
only recipient of the original message, include the user as a
recipient of the reply.

notmuch-reply.c
test/T220-reply.sh
test/T230-reply-to-sender.sh
test/T310-emacs.sh
test/T350-crypto.sh

index 75cf7ecb5068534df678e37fd0a606cd6215739e..d87ec06d83f4989a8d6563fe141fd025c656b4c4 100644 (file)
@@ -369,6 +369,14 @@ add_recipients_from_message (GMimeMessage *reply,
        }
     }
 
+    /* If no recipients were added but we found one of the user's
+     * addresses to use as a from address then the message is from the
+     * user to the user - add the discovered from address to the list
+     * of recipients so that the reply goes back to the user.
+     */
+    if (n == 0 && from_addr)
+       g_mime_message_add_recipient (reply, GMIME_ADDRESS_TYPE_TO, NULL, from_addr);
+
     return from_addr;
 }
 
index ebe710f98c55a6d9130449be5c5dc47143bff51e..4db3a95872df60e3fa8e952da5720e7110276339 100755 (executable)
@@ -180,6 +180,7 @@ test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.or
 Subject: Re: This subject is exactly 200 bytes in length. Other than its
  length there is not much of note here. Note that the length of 200 bytes
  includes the Subject: and Re: prefixes with two spaces
+To: test_suite@notmuchmail.org
 In-Reply-To: <${gen_msg_id}>
 References: <${gen_msg_id}>
 
index 134a106365c4618064218c4f5619af5f5a8d54a3..bbeaa2b9c875fae21440af832e649264b9a9c60e 100755 (executable)
@@ -203,6 +203,7 @@ test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.or
 Subject: Re: This subject is exactly 200 bytes in length. Other than its
  length there is not much of note here. Note that the length of 200 bytes
  includes the Subject: and Re: prefixes with two spaces
+To: test_suite@notmuchmail.org
 In-Reply-To: <${gen_msg_id}>
 References: <${gen_msg_id}>
 
index 5935819f4ba4404eb14802d921ff88c3cd2ea1db..cb9e99a58f7d1ded2740f5c8d28af85d13f54ba6 100755 (executable)
@@ -610,7 +610,7 @@ test_emacs "(let ((message-hidden-headers '()))
            (test-output))"
 cat <<EOF >EXPECTED
 From: Notmuch Test Suite <test_suite@notmuchmail.org>
-To: 
+To: test_suite@notmuchmail.org
 Subject: Re: Reply within emacs to an html-only message
 In-Reply-To: <${gen_msg_id}>
 Fcc: ${MAIL_DIR}/sent
@@ -623,7 +623,6 @@ EOF
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "Reply within emacs to message from self"
-test_subtest_known_broken
 add_message '[from]="test_suite@notmuchmail.org"' \
            '[to]="test_suite@notmuchmail.org"'
 test_emacs "(let ((message-hidden-headers '()))
@@ -657,7 +656,7 @@ test_emacs "(let ((message-hidden-headers '()))
              (test-output))"
 cat <<EOF >EXPECTED
 From: Notmuch Test Suite <test_suite@notmuchmail.org>
-To: 
+To: test_suite@notmuchmail.org
 Subject: Re: Quote MML tags in reply
 In-Reply-To: <test-emacs-mml-quoting@message.id>
 Fcc: ${MAIL_DIR}/sent
index a776ec35043b324efd1c38572ff18683b0afd960..73aa58dee8a8a758974edc0879e43307a4b5c7d8 100755 (executable)
@@ -388,6 +388,7 @@ output=$(notmuch reply --decrypt=true subject:"test encrypted message 002" \
     | notmuch_drop_mail_headers In-Reply-To References)
 expected='From: Notmuch Test Suite <test_suite@notmuchmail.org>
 Subject: Re: test encrypted message 002
+To: test_suite@notmuchmail.org
 
 On 01 Jan 2000 12:00:00 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
 > This is another test encrypted message.'
@@ -401,10 +402,10 @@ test_emacs "(let ((message-hidden-headers '())
   (notmuch-show \"subject:test.encrypted.message.002\")
   (notmuch-show-reply)
   (test-output))"
-# the empty To: is probably a bug, but it's not to do with encryption
-grep -v -e '^In-Reply-To:' -e '^References:' -e '^Fcc:' -e 'To:' < OUTPUT > OUTPUT.clean
+grep -v -e '^In-Reply-To:' -e '^References:' -e '^Fcc:' < OUTPUT > OUTPUT.clean
 cat <<EOF >EXPECTED
 From: Notmuch Test Suite <test_suite@notmuchmail.org>
+To: test_suite@notmuchmail.org
 Subject: Re: test encrypted message 002
 --text follows this line--
 <#secure method=pgpmime mode=signencrypt>