From abeac48522ded66e2f0e9aae704482355cb46e6a Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Thu, 24 Oct 2013 11:19:08 -0400 Subject: search: Add stable queries to thread search results These queries will match exactly the set of messages currently in the thread, even if more messages later arrive. Two queries are provided: one for matched messages and one for unmatched messages. This can be used to fix race conditions with tagging threads from search results. While tagging based on a thread: query can affect messages that arrived after the search, tagging based on stable queries affects only the messages the user was shown in the search UI. Since we want clients to be able to depend on the presence of these queries, this ushers in schema version 2. --- test/json | 2 ++ test/missing-headers | 6 ++++-- test/sexp | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/json b/test/json index b87b7f6d..e07a2904 100755 --- a/test/json +++ b/test/json @@ -26,6 +26,7 @@ test_expect_equal_json "$output" "[{\"thread\": \"XXX\", \"total\": 1, \"authors\": \"Notmuch Test Suite\", \"subject\": \"json-search-subject\", + \"query\": [\"id:$gen_msg_id\", null], \"tags\": [\"inbox\", \"unread\"]}]" @@ -59,6 +60,7 @@ test_expect_equal_json "$output" "[{\"thread\": \"XXX\", \"total\": 1, \"authors\": \"Notmuch Test Suite\", \"subject\": \"json-search-utf8-body-sübjéct\", + \"query\": [\"id:$gen_msg_id\", null], \"tags\": [\"inbox\", \"unread\"]}]" diff --git a/test/missing-headers b/test/missing-headers index f14b8784..43e861bc 100755 --- a/test/missing-headers +++ b/test/missing-headers @@ -43,7 +43,8 @@ test_expect_equal_json "$output" ' ], "thread": "XXX", "timestamp": 978709437, - "total": 1 + "total": 1, + "query": ["id:notmuch-sha1-7a6e4eac383ef958fcd3ebf2143db71b8ff01161", null] }, { "authors": "Notmuch Test Suite", @@ -56,7 +57,8 @@ test_expect_equal_json "$output" ' ], "thread": "XXX", "timestamp": 0, - "total": 1 + "total": 1, + "query": ["id:notmuch-sha1-ca55943aff7a72baf2ab21fa74fab3d632401334", null] } ]' diff --git a/test/sexp b/test/sexp index 492a82f7..be815e12 100755 --- a/test/sexp +++ b/test/sexp @@ -19,7 +19,7 @@ test_expect_equal "$output" "((((:id \"${gen_msg_id}\" :match t :excluded nil :f test_begin_subtest "Search message: sexp" add_message "[subject]=\"sexp-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"sexp-search-message\"" output=$(notmuch search --format=sexp "sexp-search-message" | notmuch_search_sanitize) -test_expect_equal "$output" "((:thread \"0000000000000002\" :timestamp 946728000 :date_relative \"2000-01-01\" :matched 1 :total 1 :authors \"Notmuch Test Suite\" :subject \"sexp-search-subject\" :tags (\"inbox\" \"unread\")))" +test_expect_equal "$output" "((:thread \"0000000000000002\" :timestamp 946728000 :date_relative \"2000-01-01\" :matched 1 :total 1 :authors \"Notmuch Test Suite\" :subject \"sexp-search-subject\" :query (\"id:$gen_msg_id\" nil) :tags (\"inbox\" \"unread\")))" test_begin_subtest "Show message: sexp, utf-8" add_message "[subject]=\"sexp-show-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-show-méssage\"" @@ -44,7 +44,7 @@ test_expect_equal "$output" "((((:id \"$id\" :match t :excluded nil :filename \" test_begin_subtest "Search message: sexp, utf-8" add_message "[subject]=\"sexp-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-search-méssage\"" output=$(notmuch search --format=sexp "jsön-search-méssage" | notmuch_search_sanitize) -test_expect_equal "$output" "((:thread \"0000000000000005\" :timestamp 946728000 :date_relative \"2000-01-01\" :matched 1 :total 1 :authors \"Notmuch Test Suite\" :subject \"sexp-search-utf8-body-sübjéct\" :tags (\"inbox\" \"unread\")))" +test_expect_equal "$output" "((:thread \"0000000000000005\" :timestamp 946728000 :date_relative \"2000-01-01\" :matched 1 :total 1 :authors \"Notmuch Test Suite\" :subject \"sexp-search-utf8-body-sübjéct\" :query (\"id:$gen_msg_id\" nil) :tags (\"inbox\" \"unread\")))" test_done -- cgit v1.2.3