Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 62A3B431FAF for ; Fri, 7 Sep 2012 04:52:57 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.3 X-Spam-Level: X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UWru7xwLO2xY for ; Fri, 7 Sep 2012 04:52:56 -0700 (PDT) Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36]) by olra.theworths.org (Postfix) with ESMTP id 32DB0431FAE for ; Fri, 7 Sep 2012 04:52:56 -0700 (PDT) Received: from localhost (unknown [192.168.200.4]) by max.feld.cvut.cz (Postfix) with ESMTP id CADCA19F32E0; Fri, 7 Sep 2012 13:52:50 +0200 (CEST) X-Virus-Scanned: IMAP AMAVIS Received: from max.feld.cvut.cz ([192.168.200.1]) by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new, port 10044) with ESMTP id iF4H32WDSwLn; Fri, 7 Sep 2012 13:52:49 +0200 (CEST) Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34]) by max.feld.cvut.cz (Postfix) with ESMTP id 1F49619F32DA; Fri, 7 Sep 2012 13:52:49 +0200 (CEST) Received: from steelpick.2x.cz (note-sojka.felk.cvut.cz [147.32.86.30]) (Authenticated sender: sojkam1) by imap.feld.cvut.cz (Postfix) with ESMTPSA id 257CF660968; Fri, 7 Sep 2012 13:52:48 +0200 (CEST) Received: from wsh by steelpick.2x.cz with local (Exim 4.80) (envelope-from ) id 1T9x7A-0002Qo-3k; Fri, 07 Sep 2012 13:52:48 +0200 From: Michal Sojka To: Michal Nazarewicz , notmuch@notmuchmail.org Subject: Re: [PATCH] notmuch-show: include Bcc header in json output In-Reply-To: <821b9893f8b26cfe624568015c52c5b7753a9eac.1346944540.git.mina86@mina86.com> References: <821b9893f8b26cfe624568015c52c5b7753a9eac.1346944540.git.mina86@mina86.com> User-Agent: Notmuch/0.14+23~g9d68aca (http://notmuchmail.org) Emacs/24.1.1 (x86_64-pc-linux-gnu) Date: Fri, 07 Sep 2012 13:52:48 +0200 Message-ID: <87pq5yaw33.fsf@steelpick.2x.cz> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Sep 2012 11:52:57 -0000 On Thu, Sep 06 2012, Michal Nazarewicz wrote: > From: Michal Nazarewicz > > --- > notmuch-show.c | 7 +++++++ > test/json | 8 ++++---- > test/test-lib.sh | 5 +++++ > 3 files changed, 16 insertions(+), 4 deletions(-) > > diff --git a/notmuch-show.c b/notmuch-show.c > index 3556293..0b7abf1 100644 > --- a/notmuch-show.c > +++ b/notmuch-show.c > @@ -233,6 +233,13 @@ format_headers_json (sprinter_t *sp, GMimeMessage *message, > sp->string (sp, recipients_string); > } > > + recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_BCC); > + recipients_string = internet_address_list_to_string (recipients, 0); > + if (recipients_string) { > + sp->map_key (sp, "Bcc"); > + sp->string (sp, recipients_string); > + } > + > if (reply) { > sp->map_key (sp, "In-reply-to"); > sp->string (sp, g_mime_object_get_header (GMIME_OBJECT (message), "In-reply-to")); > diff --git a/test/json b/test/json > index ac8fa8e..40d0ba3 100755 > --- a/test/json > +++ b/test/json > @@ -3,18 +3,18 @@ test_description="--format=json output" > . ./test-lib.sh > > test_begin_subtest "Show message: json" > -add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-show-message\"" > +add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[bcc]=\"test_suite+bcc@notmuchmail.org\"" "[body]=\"json-show-message\"" > output=$(notmuch show --format=json "json-show-message") > -test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite \", \"To\": \"Notmuch Test Suite \", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]" > +test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite \", \"To\": \"Notmuch Test Suite \", \"Bcc\": \"test_suite+bcc@notmuchmail.org\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]" > > # This should be the same output as above. > test_begin_subtest "Show message: json --body=true" > output=$(notmuch show --format=json --body=true "json-show-message") > -test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite \", \"To\": \"Notmuch Test Suite \", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]" > +test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite \", \"To\": \"Notmuch Test Suite \", \"Bcc\": \"test_suite+bcc@notmuchmail.org\",\"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]" > > test_begin_subtest "Show message: json --body=false" > output=$(notmuch show --format=json --body=false "json-show-message") > -test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite \", \"To\": \"Notmuch Test Suite \", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}}, []]]]" > +test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite \", \"To\": \"Notmuch Test Suite \", \"Bcc\": \"test_suite+bcc@notmuchmail.org\",\"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}}, []]]]" > > test_begin_subtest "Search message: json" > add_message "[subject]=\"json-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-search-message\"" > diff --git a/test/test-lib.sh b/test/test-lib.sh > index f34b1fb..e14203d 100644 > --- a/test/test-lib.sh > +++ b/test/test-lib.sh > @@ -350,6 +350,11 @@ ${additional_headers}" > ${additional_headers}" > fi > > + if [ ! -z "${template[bcc]}" ]; then > + additional_headers="Bcc: ${template[bcc]} > +${additional_headers}" > + fi > + > if [ ! -z "${template[references]}" ]; then > additional_headers="References: ${template[references]} > ${additional_headers}" > -- > 1.7.7.3 LGTM It's good that you left there a few tests without bcc header so that we have covered both cases. -Michal