From 81cbe432c1995bc541272a5711e3d90947d2bc79 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Mon, 10 Sep 2012 11:52:05 +0300 Subject: [PATCH] Re: [PATCHv3] notmuch-show: include Bcc header in json output --- c0/9e5a43bff56e66b0f4b294eb428d1c7ef57b4c | 160 ++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 c0/9e5a43bff56e66b0f4b294eb428d1c7ef57b4c diff --git a/c0/9e5a43bff56e66b0f4b294eb428d1c7ef57b4c b/c0/9e5a43bff56e66b0f4b294eb428d1c7ef57b4c new file mode 100644 index 000000000..3fb9492b8 --- /dev/null +++ b/c0/9e5a43bff56e66b0f4b294eb428d1c7ef57b4c @@ -0,0 +1,160 @@ +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 F10C6431FB6 + for ; Mon, 10 Sep 2012 01:52:01 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + 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 W1MW3rLfxk1A for ; + Mon, 10 Sep 2012 01:52:00 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 4920E431FAE + for ; Mon, 10 Sep 2012 01:52:00 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id C867210036F; + Mon, 10 Sep 2012 11:52:05 +0300 (EEST) +From: Tomi Ollila +To: Michal Nazarewicz , notmuch@notmuchmail.org +Subject: Re: [PATCHv3] notmuch-show: include Bcc header in json output +In-Reply-To: + <7b1848a5828820912e3f7b960528b0dbc6a8b361.1347258748.git.mina86@mina86.com> +References: + <7b1848a5828820912e3f7b960528b0dbc6a8b361.1347258748.git.mina86@mina86.com> +User-Agent: Notmuch/0.13.2+162~ged38330 (http://notmuchmail.org) Emacs/24.2.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +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: Mon, 10 Sep 2012 08:52:02 -0000 + +On Mon, Sep 10 2012, Michal Nazarewicz wrote: + +> From: Michal Nazarewicz +> +> With this change, emacs users can use notmuch-message-headers +> variable to configure notmuch-show display Bcc header. +> --- + +Thanks, that explains (also why my attempts to show Message-ID has failed ;) + +I applied the patch, run tests (which pass) and tested the feature -- +The Bcc field is indeed shown. + +The only annoyance for me is that in the file I picked to test had: + +BCC: user1@host.tld, user2@host.tld, + user3@host.tld, user4@host.tld + +notmuch displayed this content as + + Bcc: user1@host.tld, user2@host.tld, +user3@host.tld, user4@host.tld + +I think this should be "fixed" (somehow (*)) in the future, but this +should not hold this patch. + ++1 + +Tomi + +(*) How that is done is another issue, should the cli or emacs do it, +(i.e. which interface modifies spacing information) and should this be done +generally to all headers. Is the solution to change all whitespace to one +space or indent subsequent on screen... + +> 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 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2