about summary refs log tree commit homepage
path: root/lib/PublicInbox/Search.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/Search.pm')
-rw-r--r--lib/PublicInbox/Search.pm21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index a1c423c8..802984b0 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -372,6 +372,27 @@ sub lookup_mail { # no ghosts!
         });
 }
 
+sub lookup_article {
+        my ($self, $num) = @_;
+        my $term = 'XNUM'.$num;
+        my $smsg;
+        eval {
+                retry_reopen($self, sub {
+                        my $db = $self->{skel} || $self->{xdb};
+                        my $head = $db->postlist_begin($term);
+                        return if $head == $db->postlist_end($term);
+                        my $doc_id = $head->get_docid;
+                        return unless defined $doc_id;
+                        # raises on error:
+                        my $doc = $db->get_document($doc_id);
+                        $smsg = PublicInbox::SearchMsg->wrap($doc);
+                        $smsg->load_expand;
+                        $smsg->{doc_id} = $doc_id;
+                });
+        };
+        $smsg;
+}
+
 sub each_smsg_by_mid {
         my ($self, $mid, $cb) = @_;
         my $xdb = $self->{xdb};