From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 31C181F9FD for ; Fri, 5 Mar 2021 04:03:05 +0000 (UTC) From: Eric Wong 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 Message-Id: <20210305040305.5510-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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{''}->{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;