reply: Include sender as recipient if they were the original recipient

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.
This commit is contained in:
David Edmondson 2018-10-01 17:50:47 +01:00 committed by David Bremner
parent 0d0e2869b9
commit 576cff7654
5 changed files with 15 additions and 5 deletions

View 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; return from_addr;
} }

View file

@ -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 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 length there is not much of note here. Note that the length of 200 bytes
includes the Subject: and Re: prefixes with two spaces includes the Subject: and Re: prefixes with two spaces
To: test_suite@notmuchmail.org
In-Reply-To: <${gen_msg_id}> In-Reply-To: <${gen_msg_id}>
References: <${gen_msg_id}> References: <${gen_msg_id}>

View file

@ -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 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 length there is not much of note here. Note that the length of 200 bytes
includes the Subject: and Re: prefixes with two spaces includes the Subject: and Re: prefixes with two spaces
To: test_suite@notmuchmail.org
In-Reply-To: <${gen_msg_id}> In-Reply-To: <${gen_msg_id}>
References: <${gen_msg_id}> References: <${gen_msg_id}>

View file

@ -610,7 +610,7 @@ test_emacs "(let ((message-hidden-headers '()))
(test-output))" (test-output))"
cat <<EOF >EXPECTED cat <<EOF >EXPECTED
From: Notmuch Test Suite <test_suite@notmuchmail.org> From: Notmuch Test Suite <test_suite@notmuchmail.org>
To: To: test_suite@notmuchmail.org
Subject: Re: Reply within emacs to an html-only message Subject: Re: Reply within emacs to an html-only message
In-Reply-To: <${gen_msg_id}> In-Reply-To: <${gen_msg_id}>
Fcc: ${MAIL_DIR}/sent Fcc: ${MAIL_DIR}/sent
@ -623,7 +623,6 @@ EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "Reply within emacs to message from self" test_begin_subtest "Reply within emacs to message from self"
test_subtest_known_broken
add_message '[from]="test_suite@notmuchmail.org"' \ add_message '[from]="test_suite@notmuchmail.org"' \
'[to]="test_suite@notmuchmail.org"' '[to]="test_suite@notmuchmail.org"'
test_emacs "(let ((message-hidden-headers '())) test_emacs "(let ((message-hidden-headers '()))
@ -657,7 +656,7 @@ test_emacs "(let ((message-hidden-headers '()))
(test-output))" (test-output))"
cat <<EOF >EXPECTED cat <<EOF >EXPECTED
From: Notmuch Test Suite <test_suite@notmuchmail.org> From: Notmuch Test Suite <test_suite@notmuchmail.org>
To: To: test_suite@notmuchmail.org
Subject: Re: Quote MML tags in reply Subject: Re: Quote MML tags in reply
In-Reply-To: <test-emacs-mml-quoting@message.id> In-Reply-To: <test-emacs-mml-quoting@message.id>
Fcc: ${MAIL_DIR}/sent Fcc: ${MAIL_DIR}/sent

View file

@ -388,6 +388,7 @@ output=$(notmuch reply --decrypt=true subject:"test encrypted message 002" \
| notmuch_drop_mail_headers In-Reply-To References) | notmuch_drop_mail_headers In-Reply-To References)
expected='From: Notmuch Test Suite <test_suite@notmuchmail.org> expected='From: Notmuch Test Suite <test_suite@notmuchmail.org>
Subject: Re: test encrypted message 002 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: On 01 Jan 2000 12:00:00 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
> This is another test encrypted message.' > 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 \"subject:test.encrypted.message.002\")
(notmuch-show-reply) (notmuch-show-reply)
(test-output))" (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:' < OUTPUT > OUTPUT.clean
grep -v -e '^In-Reply-To:' -e '^References:' -e '^Fcc:' -e 'To:' < OUTPUT > OUTPUT.clean
cat <<EOF >EXPECTED cat <<EOF >EXPECTED
From: Notmuch Test Suite <test_suite@notmuchmail.org> From: Notmuch Test Suite <test_suite@notmuchmail.org>
To: test_suite@notmuchmail.org
Subject: Re: test encrypted message 002 Subject: Re: test encrypted message 002
--text follows this line-- --text follows this line--
<#secure method=pgpmime mode=signencrypt> <#secure method=pgpmime mode=signencrypt>