]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Search.pm
Allow images and HTML
[public-inbox.git] / lib / PublicInbox / Search.pm
index 523003b3c269ae42e9ee210e91415b2846735daa..273cc57cf94ba8b12d18acfcefd4aaa13e8a2c7a 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 # based on notmuch, but with no concept of folders, files or flags
 #
@@ -118,9 +118,10 @@ my %bool_pfx_external = (
        dfpre => 'XDFPRE',
        dfpost => 'XDFPOST',
        dfblob => 'XDFPRE XDFPOST',
+       patchid => 'XDFID',
 );
 
-my $non_quoted_body = 'XNQ XDFN XDFA XDFB XDFHH XDFCTX XDFPRE XDFPOST';
+my $non_quoted_body = 'XNQ XDFN XDFA XDFB XDFHH XDFCTX XDFPRE XDFPOST XDFID';
 my %prob_prefix = (
        # for mairix compatibility
        s => 'S',
@@ -178,6 +179,7 @@ EOF
        'dfpre:' => 'match pre-image git blob ID',
        'dfpost:' => 'match post-image git blob ID',
        'dfblob:' => 'match either pre or post-image git blob ID',
+       'patchid:' => "match `git patch-id --stable' output",
        'rt:' => <<EOF,
 match received time, like `d:' if sender's clock was correct
 EOF
@@ -458,8 +460,9 @@ sub _enquire_once { # retry_reopen callback
                $enquire->set_sort_by_relevance_then_value(TS, !$opts->{asc});
        }
 
-       # `mairix -t / --threads' or JMAP collapseThreads
-       if ($opts->{threads} && has_threadid($self)) {
+       # `lei q -t / --threads' or JMAP collapseThreads; but don't collapse
+       # on `-tt' ({threads} > 1) which sets the Flagged|Important keyword
+       if (($opts->{threads} // 0) == 1 && has_threadid($self)) {
                $enquire->set_collapse_key(THREADID);
        }
        $enquire->get_mset($opts->{offset} || 0, $opts->{limit} || 50);
@@ -541,9 +544,10 @@ sub help {
        \@ret;
 }
 
+# always returns a scalar value
 sub int_val ($$) {
        my ($doc, $col) = @_;
-       my $val = $doc->get_value($col) or return; # undefined is '' in Xapian
+       my $val = $doc->get_value($col) or return undef; # undef is '' in Xapian
        sortable_unserialise($val) + 0; # PV => IV conversion
 }