about summary refs log tree commit homepage
path: root/lib/PublicInbox/ExtMsg.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-08-20 20:24:52 +0000
committerEric Wong <e@yhbt.net>2020-08-20 21:11:20 +0000
commite46c349fc3b26aadb5413f8ee651f9a5016d3604 (patch)
tree4eccff0491a5476ad6bac6e18a8192c37a74f448 /lib/PublicInbox/ExtMsg.pm
parent69db106e1eedb0468ccff85e9304667471bc042b (diff)
downloadpublic-inbox-e46c349fc3b26aadb5413f8ee651f9a5016d3604.tar.gz
Once again, over.sqlite3 contains everything necessary for
Message-ID resolution.  Also, Xapian may be completely
unnecessary with the advent of over.sqlite3, but that's for
another time.
Diffstat (limited to 'lib/PublicInbox/ExtMsg.pm')
-rw-r--r--lib/PublicInbox/ExtMsg.pm21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/PublicInbox/ExtMsg.pm b/lib/PublicInbox/ExtMsg.pm
index d7917b34..5c23dc31 100644
--- a/lib/PublicInbox/ExtMsg.pm
+++ b/lib/PublicInbox/ExtMsg.pm
@@ -11,6 +11,7 @@ use warnings;
 use PublicInbox::Hval qw(ascii_html prurl mid_href);
 use PublicInbox::WwwStream qw(html_oneshot);
 use PublicInbox::Smsg;
+use PublicInbox::Search qw(mdocid);
 our $MIN_PARTIAL_LEN = 16;
 
 # TODO: user-configurable
@@ -29,13 +30,10 @@ our @EXT_URL = map { ascii_html($_) } (
 
 sub PARTIAL_MAX () { 100 }
 
-sub mids_from_mset { # Search::retry_reopen callback
-        [ map { PublicInbox::Smsg::from_mitem($_)->{mid} } $_[0]->items ];
-}
-
 sub search_partial ($$) {
-        my ($srch, $mid) = @_;
+        my ($ibx, $mid) = @_;
         return if length($mid) < $MIN_PARTIAL_LEN;
+        my $srch = $ibx->search or return;
         my $opt = { limit => PARTIAL_MAX, mset => 2 };
         my @try = ("m:$mid*");
         my $chop = $mid;
@@ -63,14 +61,17 @@ sub search_partial ($$) {
                 }
         }
 
+        my $n = $srch->{nshard} // 1;
         foreach my $m (@try) {
                 # If Xapian can't handle the wildcard since it
                 # has too many results.  $@ can be
                 # Search::Xapian::QueryParserError or even:
                 # "something terrible happened at ../Search/Xapian/Enquire.pm"
                 my $mset = eval { $srch->query($m, $opt) } or next;
-                my $mids = $srch->retry_reopen(\&mids_from_mset, $mset);
-                return $mids if scalar(@$mids);
+                my @mids = map {
+                        $_->{mid}
+                } @{$ibx->over->get_all(map { mdocid($n, $_) } $mset->items)};
+                return \@mids if scalar(@mids);
         }
 }
 
@@ -111,8 +112,7 @@ sub ext_msg {
         # fall back to partial MID matching
         my @partial;
         my $n_partial = 0;
-        my $srch = $cur->search;
-        my $mids = search_partial($srch, $mid) if $srch;
+        my $mids = search_partial($cur, $mid);
         if ($mids) {
                 $n_partial = scalar(@$mids);
                 push @partial, [ $cur, $mids ];
@@ -121,8 +121,7 @@ sub ext_msg {
         # can't find a partial match in current inbox, try the others:
         if (!$n_partial && length($mid) >= $MIN_PARTIAL_LEN) {
                 foreach my $ibx (@$ibxs) {
-                        $srch = $ibx->search or next;
-                        $mids = search_partial($srch, $mid) or next;
+                        $mids = search_partial($ibx, $mid) or next;
                         $n_partial += scalar(@$mids);
                         push @partial, [ $ibx, $mids];
                         last if $n_partial >= PARTIAL_MAX;