From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id B596C431FAF for ; Sun, 9 Sep 2012 23:35:40 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.8 X-Spam-Level: X-Spam-Status: No, score=-0.8 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7] 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 lx7z1iyg14KB for ; Sun, 9 Sep 2012 23:35:39 -0700 (PDT) Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com [74.125.83.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id A8BF9431FAE for ; Sun, 9 Sep 2012 23:35:38 -0700 (PDT) Received: by eekb47 with SMTP id b47so1003639eek.26 for ; Sun, 09 Sep 2012 23:35:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; bh=9PofzNbNy5b0CBsioczxEEX6Gx1skFRtjds85cZZDYU=; b=cecl5VKn41Fo5EA1LGX0RzXCBCo79Kt0eqC/nQF213ybfphzq9NyWDitmD8190Tps0 e4PXUcId4dE1x1sglmi1E1DwjcUkIy3Is3Ix4UylopMrETbCOmYro64D0LBidACS1nKu AH1yjK3iqBszVtTv/oOqRrr/oDH6Ofb4Z8GtAzmYDZDn9IpJvHvh4LbaYg17uXA33Vum X9ym7tIZiAkNsy8ZxYcfMn0Dps4wZPavPEjq8yI2Lj3J56bB3fw3cklf0TTg79SBiorm bKxv3Rt6sjHMDPJICoSu+rNfjJY53jhoQretmDlVvQgIbxNnUrDh3iQVYPUj6MRBsVMo Mc1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=9PofzNbNy5b0CBsioczxEEX6Gx1skFRtjds85cZZDYU=; b=DtPXVKpyf4/X8M5hYLk4Fn08TA7x5pH/F70T1IkUFabqAe55B0E9NXzfcNFuT4HKNe a4hYvAU/3Ha41XdVGLLRIU1h388Tn+9rdk3KuXCYqT0ZcULOdMnyaQJkERB0XeOlcuIb ranVAYvwh33I5DjbU1PqBX2J1j7MpqWEb7V6QE9IADsfhoSVgIcK8eRd2UOt0rz8xsOJ UXpK0j35DKj649DjVgE9mYXS5my++wLCJOTXpdw8c0Mz4Rz1lRTqb18PAGw92H5ugUsa +Cyr4KhPDe4TWCij8Ux7zLx6BvADBH3UPwUGA9DdWAXiLxO8rauafx2puxbPPojzPY8m WmOg== Received: by 10.204.128.196 with SMTP id l4mr3521453bks.21.1347258937160; Sun, 09 Sep 2012 23:35:37 -0700 (PDT) Received: by 10.204.128.196 with SMTP id l4mr3521450bks.21.1347258936935; Sun, 09 Sep 2012 23:35:36 -0700 (PDT) Received: from mpn-glaptop.corp.google.com (dhcp-172-16-75-166.zrh.corp.google.com [172.16.75.166]) by mx.google.com with ESMTPS id hs2sm5957891bkc.1.2012.09.09.23.35.35 (version=SSLv3 cipher=OTHER); Sun, 09 Sep 2012 23:35:35 -0700 (PDT) From: Michal Nazarewicz To: notmuch@notmuchmail.org Subject: [PATCHv3] notmuch-show: include Bcc header in json output Date: Mon, 10 Sep 2012 08:35:30 +0200 Message-Id: <7b1848a5828820912e3f7b960528b0dbc6a8b361.1347258748.git.mina86@mina86.com> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: References: X-Gm-Message-State: ALoCoQkFamdTaufbbbuM6ipMfNXAkJki7tCEcT0F89BbrlcHczkaFVfAZVC3XbLR9oGyo85c50N/klmRSCHM+3LKkLZwlJEFZtS8/84/NH3NMIqN0z6IzkNRnaTuLIj8Lu7RYL71d11FYsmK4sSofdAn6pp52w+5HmdyttyoapYtX+vgXBUYsD5Z7Q/qqpAX+HITP8nMJjj1aW0eADGxfm85/uApaaCk0g== 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 06:35:41 -0000 From: Michal Nazarewicz With this change, emacs users can use notmuch-message-headers variable to configure notmuch-show display Bcc header. --- 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