From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] lei q: one -t shouldn't set `flagged' on external mail
Date: Fri, 5 Mar 2021 04:03:05 +0000 [thread overview]
Message-ID: <20210305040305.5510-1-e@80x24.org> (raw)
We only want to set `flagged' if a user requests it via
a two '-t' switches.
Fixes: 232f8e376fe2856c ("lei q: -tt marks direct hits as flagged")
---
lib/PublicInbox/LeiXSearch.pm | 6 +++---
t/lei-q-thread.t | 8 ++++++--
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index 3270b420..f2c8c02e 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -148,7 +148,7 @@ sub query_thread_mset { # for --threads
my $mset;
my $each_smsg = $lei->{ovv}->ovv_each_smsg_cb($lei, $ibxish);
my $can_kw = !!$ibxish->can('msg_keywords');
- my $fl = $lei->{opt}->{threads} > 1;
+ my $fl = $lei->{opt}->{threads} > 1 ? [ 'flagged' ] : undef;
do {
$mset = $srch->mset($mo->{qstr}, $mo);
mset_progress($lei, $desc, $mset->size,
@@ -165,8 +165,8 @@ sub query_thread_mset { # for --threads
if ($mitem) {
if ($can_kw) {
mitem_kw($smsg, $mitem, $fl);
- } else {
- $smsg->{kw} = [ 'flagged' ];
+ } elsif ($fl) {
+ $smsg->{kw} = $fl;
}
}
$each_smsg->($smsg, $mitem);
diff --git a/t/lei-q-thread.t b/t/lei-q-thread.t
index 0ddf47a6..28c639f5 100644
--- a/t/lei-q-thread.t
+++ b/t/lei-q-thread.t
@@ -41,8 +41,12 @@ test_lei(sub {
'flagged set in direct hit');
'TODO' or is_deeply($m{'<testmessage@example.com>'}->{kw}, ['draft'],
'flagged set in direct hit');
- lei_ok qw(q -t -t m:testmessage@example.com --only), "$ro_home/t2";
+ lei_ok qw(q -tt m:testmessage@example.com --only), "$ro_home/t2";
$res = json_utf8->decode($lei_out);
- is_deeply($res->[0]->{kw}, [ 'flagged' ], 'flagged set on external');
+ is_deeply($res->[0]->{kw}, [ 'flagged' ],
+ 'flagged set on external with -tt');
+ lei_ok qw(q -t m:testmessage@example.com --only), "$ro_home/t2";
+ $res = json_utf8->decode($lei_out);
+ ok(!exists($res->[0]->{kw}), 'flagged not set on external with 1 -t');
});
done_testing;
reply other threads:[~2021-03-05 4:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210305040305.5510-1-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).