- eval { require PublicInbox::Search };
- my $have_xap = $@ ? 0 : 1;
- my (@nox, @pfx);
-
- foreach my $k (keys %$pi_config) {
- $k =~ /\Apublicinbox\.([A-Z0-9a-z-]+)\.url\z/ or next;
- my $list = $1;
- next if $list eq $listname;
-
- my $git_dir = $pi_config->{"publicinbox.$list.mainrepo"};
- defined $git_dir or next;
-
- my $url = $pi_config->{"publicinbox.$list.url"};
- defined $url or next;
-
- $url =~ s!/+\z!!;
-
- # try to find the URL with Xapian to avoid forking
- if ($have_xap) {
- my $s;
- my $doc_id = eval {
- $s = PublicInbox::Search->new($git_dir);
- $s->find_unique_doc_id('mid', $mid);
- };
- if ($@) {
- # xapian not configured for this repo
- } else {
- # maybe we found it!
- return r302($url, $mid) if (defined $doc_id);
-
- # no point in trying the fork fallback if we
- # know Xapian is up-to-date but missing the
- # message in the current repo
- push @pfx, { git_dir => $git_dir, url => $url };
- next;
- }
+ eval { require PublicInbox::Msgmap };
+ my $have_mm = $@ ? 0 : 1;
+ my (@ibx, @found);
+
+ $ctx->{www}->{pi_config}->each_inbox(sub {
+ my ($other) = @_;
+ return if $other->{name} eq $cur->{name} || !$other->base_url;
+
+ my $mm = $other->mm or return;
+
+ # try to find the URL with Msgmap to avoid forking
+ my $num = $mm->num_for($mid);
+ if (defined $num) {
+ push @found, $other;
+ } else {
+ # no point in trying the fork fallback if we
+ # know Xapian is up-to-date but missing the
+ # message in the current repo
+ push @ibx, $other;