]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: disable subject threading
authorEric Wong <e@80x24.org>
Mon, 2 May 2016 03:20:22 +0000 (03:20 +0000)
committerEric Wong <e@80x24.org>
Mon, 2 May 2016 17:57:07 +0000 (17:57 +0000)
Broken threads should be exposed to hopefully encourage people to
use proper mail clients which set In-Reply-To headers.

lib/PublicInbox/SearchView.pm
lib/PublicInbox/Thread.pm
lib/PublicInbox/View.pm

index 41d32007e79c6f5f42c34db84456fcd0e6f9ab4e..c0cd1ffd6ec6dd0dda984806ca872ba0b61d6b47 100644 (file)
@@ -11,6 +11,7 @@ use PublicInbox::View;
 use PublicInbox::MID qw(mid2path mid_clean mid_mime);
 use Email::MIME;
 require PublicInbox::Git;
+require PublicInbox::Thread;
 our $LIM = 50;
 
 sub sres_top_html {
@@ -151,23 +152,19 @@ sub tdump {
        } ($mset->items);
 
        my @rootset;
-       my $th = PublicInbox::View::thread_results(\@m, 0, $q->{r});
-       if ($q->{r}) {
+       my $th = PublicInbox::Thread->new(@m);
+       $th->thread;
+       if ($q->{r}) { # order by relevance
                $th->order(sub {
                        sort { (eval { $pct{$b->topmost->messageid} } || 0)
                                        <=>
                                (eval { $pct{$a->topmost->messageid} } || 0)
                        } @_;
                });
-               @rootset = $th->rootset;
-       } else {
-               @rootset = sort {
-                       (eval { $b->topmost->message->header('X-PI-TS') } || 0)
-                               <=>
-                       (eval { $a->topmost->message->header('X-PI-TS') } || 0)
-               } $th->rootset;
+       } else { # order by time (default for threaded view)
+               $th->order(*PublicInbox::View::sort_ts);
        }
-
+       @rootset = $th->rootset;
        my $git = $ctx->{git} ||= PublicInbox::Git->new($ctx->{git_dir});
        my $state = {
                ctx => $ctx,
index 781fffff2d5806d05390b66288c413a011745590..44a565ad3c7e267196e086ceeb3e00be174a3197 100644 (file)
@@ -12,6 +12,20 @@ package PublicInbox::Thread;
 use strict;
 use warnings;
 use base qw(Mail::Thread);
+# WARNING! both these Mail::Thread knobs were found by inspecting
+# the Mail::Thread 2.55 source code, and we have some monkey patches
+# in PublicInbox::Thread to fix memory leaks.  Since Mail::Thread
+# appears unmaintained, I suppose it's safe to depend on these
+# variables for now:
+{
+       no warnings 'once';
+       # we want strict threads to expose (and hopefully discourage)
+       # use of broken email clients
+       $Mail::Thread::nosubject = 1;
+       # Keep ghosts with only a single direct child,
+       # don't hide that there may be missing messages.
+       $Mail::Thread::noprune = 1;
+}
 
 if ($Mail::Thread::VERSION <= 2.55) {
        eval q(sub _container_class { 'PublicInbox::Thread::Container' });
index 63810dcbcaca74d81e45dedb1ab4c4e112381c4f..70eb44e5b64768a0b6169e3c6c2af2cae853615a 100644 (file)
@@ -670,21 +670,11 @@ sub msg_timestamp {
 }
 
 sub thread_results {
-       my ($msgs, $nosubject, $nosort) = @_;
+       my ($msgs) = @_;
        require PublicInbox::Thread;
        my $th = PublicInbox::Thread->new(@$msgs);
-
-       # WARNING! both these Mail::Thread knobs were found by inspecting
-       # the Mail::Thread 2.55 source code, and we have some monkey patches
-       # in PublicInbox::Thread to fix memory leaks.  Since Mail::Thread
-       # appears unmaintained, I suppose it's safe to depend on these
-       # variables for now:
-       no warnings 'once';
-       $Mail::Thread::nosubject = $nosubject;
-       # Keep ghosts with only a single direct child:
-       $Mail::Thread::noprune = 1;
        $th->thread;
-       $th->order(*sort_ts) unless $nosort;
+       $th->order(*sort_ts);
        $th
 }
 
@@ -879,7 +869,7 @@ sub emit_index_topics {
                my $sres = $state->{srch}->query('', \%opts);
                my $nr = scalar @{$sres->{msgs}} or last;
 
-               for (thread_results(load_results($sres), 1)->rootset) {
+               for (thread_results(load_results($sres))->rootset) {
                        add_topic($state, $_, 0);
                }
                $opts{offset} += $nr;