diff options
author | Eric Wong <e@80x24.org> | 2017-10-03 19:43:30 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2017-10-03 20:00:41 +0000 |
commit | 38c481a5438593cff686709493a70b8a6b3033d1 (patch) | |
tree | c288246c52611759bfddcbb4bb371a3bd1bb789e /lib/PublicInbox/SearchThread.pm | |
parent | 2aa29ee6a35f5be2d76c39ccc50bf7a34075e2bd (diff) | |
download | public-inbox-38c481a5438593cff686709493a70b8a6b3033d1.tar.gz |
Since we attempt to fill in threads by Subject, our thread skeletons can cross actual thread IDs, leading to the possibility of false ghosts showing up in the skeleton. Try to fill in the ghosts as well as possible by performing a message lookup.
Diffstat (limited to 'lib/PublicInbox/SearchThread.pm')
-rw-r--r-- | lib/PublicInbox/SearchThread.pm | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/PublicInbox/SearchThread.pm b/lib/PublicInbox/SearchThread.pm index 2966907a..6fbce15c 100644 --- a/lib/PublicInbox/SearchThread.pm +++ b/lib/PublicInbox/SearchThread.pm @@ -22,14 +22,15 @@ use strict; use warnings; sub thread { - my ($messages, $ordersub) = @_; + my ($messages, $ordersub, $srch) = @_; my $id_table = {}; _add_message($id_table, $_) foreach @$messages; my $rootset = [ grep { - !delete($_->{parent}) && $_->visible } values %$id_table ]; + !delete($_->{parent}) && $_->visible($srch) + } values %$id_table ]; $id_table = undef; $rootset = $ordersub->($rootset); - $_->order_children($ordersub) for @$rootset; + $_->order_children($ordersub, $srch) for @$rootset; $rootset; } @@ -129,20 +130,21 @@ sub has_descendent { # Do not show/keep ghosts iff they have no children. Sometimes # a ghost Message-ID is the result of a long header line # being folded/mangled by a MUA, and not a missing message. -sub visible ($) { - my ($self) = @_; - $self->{smsg} || scalar values %{$self->{children}}; +sub visible ($$) { + my ($self, $srch) = @_; + ($self->{smsg} ||= eval { $srch->lookup_mail($self->{id}) }) || + (scalar values %{$self->{children}}); } sub order_children { - my ($cur, $ordersub) = @_; + my ($cur, $ordersub, $srch) = @_; my %seen = ($cur => 1); # self-referential loop prevention my @q = ($cur); while (defined($cur = shift @q)) { my $c = $cur->{children}; # The hashref here... - $c = [ grep { !$seen{$_}++ && visible($_) } values %$c ]; + $c = [ grep { !$seen{$_}++ && visible($_, $srch) } values %$c ]; $c = $ordersub->($c) if scalar @$c > 1; $cur->{children} = $c; # ...becomes an arrayref push @q, @$c; |