user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH 0/2] better ghost handling
@ 2016-06-20  7:22 Eric Wong
  2016-06-20  7:22 ` [PATCH 1/2] www: improve topic view by scanning for ghosts Eric Wong
  2016-06-20  7:22 ` [PATCH 2/2] nntp: use lookup_mail instead of lookup_message Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2016-06-20  7:22 UTC (permalink / raw)
  To: meta

Improve the handling of ghosts in the WWW topic view;
which lead me to a related NNTP cleanup.

Eric Wong (2):
      www: improve topic view by scanning for ghosts
      nntp: use lookup_mail instead of lookup_message

 lib/PublicInbox/NNTP.pm      |  6 ++----
 lib/PublicInbox/Search.pm    |  6 ++++++
 lib/PublicInbox/SearchMsg.pm |  2 +-
 lib/PublicInbox/View.pm      | 14 +++++++++++---
 4 files changed, 20 insertions(+), 8 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] www: improve topic view by scanning for ghosts
  2016-06-20  7:22 [PATCH 0/2] better ghost handling Eric Wong
@ 2016-06-20  7:22 ` Eric Wong
  2016-06-20  7:22 ` [PATCH 2/2] nntp: use lookup_mail instead of lookup_message Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2016-06-20  7:22 UTC (permalink / raw)
  To: meta

This should help avoid having too many fake top-level
messages in the topic view since we only have a partial
window for threading results.
---
 lib/PublicInbox/Search.pm    |  6 ++++++
 lib/PublicInbox/SearchMsg.pm |  2 +-
 lib/PublicInbox/View.pm      | 14 +++++++++++---
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index 856c8c1..8c0bab1 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -227,6 +227,12 @@ sub lookup_message {
 	$smsg;
 }
 
+sub lookup_mail { # no ghosts!
+	my ($self, $mid) = @_;
+	my $smsg = lookup_message($self, $mid);
+	PublicInbox::SearchMsg->load_doc($smsg->{doc});
+}
+
 sub find_unique_doc_id {
 	my ($self, $term, $value) = @_;
 
diff --git a/lib/PublicInbox/SearchMsg.pm b/lib/PublicInbox/SearchMsg.pm
index 28c2037..d41d243 100644
--- a/lib/PublicInbox/SearchMsg.pm
+++ b/lib/PublicInbox/SearchMsg.pm
@@ -35,7 +35,7 @@ sub get_val ($$) {
 
 sub load_doc {
 	my ($class, $doc) = @_;
-	my $data = $doc->get_data;
+	my $data = $doc->get_data or return;
 	my $ts = get_val($doc, &PublicInbox::Search::TS);
 	utf8::decode($data);
 	my ($subj, $from, $refs, $to, $cc) = split(/\n/, $data);
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 006da8d..dfae44f 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -741,19 +741,27 @@ sub sort_ts {
 	} @_;
 }
 
+sub _tryload_ghost ($$) {
+	my ($srch, $node) = @_;
+	my $mid = $node->messageid;
+	my $smsg = $srch->lookup_mail($mid) or return;
+	$smsg->mini_mime;
+}
+
 # accumulate recent topics if search is supported
 # returns 1 if done, undef if not
 sub add_topic {
 	my ($state, $node, $level) = @_;
 	return unless $node;
 	my $child_adjust = 1;
-
-	if (my $x = $node->message) {
+	my $srch = $state->{srch};
+	my $x = $node->message || _tryload_ghost($srch, $node);
+	if ($x) {
 		$x = $x->header_obj;
 		my $subj;
 
 		$subj = $x->header('Subject');
-		$subj = $state->{srch}->subject_normalized($subj);
+		$subj = $srch->subject_normalized($subj);
 
 		if (++$state->{subjs}->{$subj} == 1) {
 			push @{$state->{order}}, [ $level, $subj ];

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] nntp: use lookup_mail instead of lookup_message
  2016-06-20  7:22 [PATCH 0/2] better ghost handling Eric Wong
  2016-06-20  7:22 ` [PATCH 1/2] www: improve topic view by scanning for ghosts Eric Wong
@ 2016-06-20  7:22 ` Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2016-06-20  7:22 UTC (permalink / raw)
  To: meta

lookup_mail is safer since it won't inadvertently load ghosts.
---
 lib/PublicInbox/NNTP.pm | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 93f654f..4b116a7 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -711,8 +711,7 @@ sub hdr_xref ($$$) { # optimize XHDR Xref [range] for rtin
 
 sub search_header_for {
 	my ($srch, $mid, $field) = @_;
-	my $smsg = $srch->lookup_message($mid) or return;
-	$smsg = PublicInbox::SearchMsg->load_doc($smsg->{doc});
+	my $smsg = $srch->lookup_mail($mid) or return;
 	$smsg->$field;
 }
 
@@ -847,10 +846,9 @@ sub cmd_over ($;$) {
 	my ($self, $range) = @_;
 	if ($range && $range =~ /\A<(.+)>\z/) {
 		my ($ng, $n) = mid_lookup($self, $1);
-		my $smsg = $ng->search->lookup_message($range) or
+		my $smsg = $ng->search->lookup_mail($range) or
 			return '430 No article with that message-id';
 		more($self, '224 Overview information follows (multi-line)');
-		$smsg = PublicInbox::SearchMsg->load_doc($smsg->{doc});
 
 		# Only set article number column if it's the current group
 		my $self_ng = $self->{ng};

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-06-20  7:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-20  7:22 [PATCH 0/2] better ghost handling Eric Wong
2016-06-20  7:22 ` [PATCH 1/2] www: improve topic view by scanning for ghosts Eric Wong
2016-06-20  7:22 ` [PATCH 2/2] nntp: use lookup_mail instead of lookup_message 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).