user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH] view: fix topic threading when ghosts are present
@ 2016-06-22  6:06  7% Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2016-06-22  6:06 UTC (permalink / raw)
  To: meta

This fixes a bug where a message replying to a ghost would
accidentally be added to the wrong topic in the index/topic
view.

Before commit 76d8f68dc273e54809ad69cfe49e141003f790ef ("view:
avoid recursion in topic index"), we would refuse to indent a
topic which started with a ghost which hid the problem.  Now we
inform the user the thread started elsewhere.
---
 lib/PublicInbox/View.pm | 47 ++++++++++++++++++++++-------------------------
 1 file changed, 22 insertions(+), 25 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 8e81391..8d2e542 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -748,8 +748,7 @@ sub sort_ts {
 }
 
 sub _tryload_ghost ($$) {
-	my ($srch, $node) = @_;
-	my $mid = $node->messageid;
+	my ($srch, $mid) = @_;
 	my $smsg = $srch->lookup_mail($mid) or return;
 	$smsg->mini_mime;
 }
@@ -758,30 +757,25 @@ sub _tryload_ghost ($$) {
 # returns 1 if done, undef if not
 sub add_topic {
 	my ($state, $level, $node) = @_;
-	my $child_adjust = 1;
 	my $srch = $state->{srch};
-	my $x = $node->message || _tryload_ghost($srch, $node);
+	my $mid = $node->messageid;
+	my $x = $node->message || _tryload_ghost($srch, $mid);
+	my ($subj, $ts);
 	if ($x) {
 		$x = $x->header_obj;
-		my $subj;
-
 		$subj = $x->header('Subject');
 		$subj = $srch->subject_normalized($subj);
-
-		if (++$state->{subjs}->{$subj} == 1) {
-			push @{$state->{order}}, [ $level, $subj ];
-		}
-
-		my $mid = mid_clean($x->header_raw('Message-ID'));
-
-		my $ts = $x->header('X-PI-TS');
-		my $exist = $state->{latest}->{$subj};
-		if (!$exist || $exist->[1] < $ts) {
-			$state->{latest}->{$subj} = [ $mid, $ts ];
-		}
-	} else {
-		# ghost message, do not bump level
-		$child_adjust = 0;
+		$ts = $x->header('X-PI-TS');
+	} else { # ghost message, do not bump level
+		$ts = -666;
+		$subj = "<$mid>";
+	}
+	if (++$state->{subjs}->{$subj} == 1) {
+		push @{$state->{order}}, [ $level, $subj ];
+	}
+	my $exist = $state->{latest}->{$subj};
+	if (!$exist || $exist->[1] < $ts) {
+		$state->{latest}->{$subj} = [ $mid, $ts ];
 	}
 }
 
@@ -802,7 +796,6 @@ sub emit_topics {
 		my $n = delete $subjs->{$subj};
 		my ($mid, $ts) = @{delete $latest->{$subj}};
 		$mid = PublicInbox::Hval->new_msgid($mid)->as_href;
-		$subj = PublicInbox::Hval->new($subj)->as_html;
 		$pfx = indent_for($level);
 		my $nl = $level == $prev ? "\n" : '';
 		if ($nl && $cur) {
@@ -811,10 +804,14 @@ sub emit_topics {
 		}
 		$cur ||= [ $ts, '' ];
 		$cur->[0] = $ts if $ts > $cur->[0];
-		$cur->[1] .= $nl . $pfx . th_pfx($level) .
-				"<a\nhref=\"$mid/t/#u\"><b>" .
-				$subj . "</b></a>\n";
+		$cur->[1] .= $nl . $pfx . th_pfx($level);
+		if ($ts == -666) { # ghost
+			$cur->[1] .= ghost_parent('', $mid) . "\n";
+			next; # child will have mbox / atom link
+		}
 
+		$subj = PublicInbox::Hval->new($subj)->as_html;
+		$cur->[1] .= "<a\nhref=\"$mid/t/#u\"><b>$subj</b></a>\n";
 		$ts = fmt_ts($ts);
 		my $attr = " $ts UTC";
 

^ permalink raw reply related	[relevance 7%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-06-22  6:06  7% [PATCH] view: fix topic threading when ghosts are present Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).