X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FSearchMsg.pm;h=afba8b1a814c92c978c37c1ec3f44ea5b6a443e9;hb=3d41aa23f35501ca92aab8aa42980fa73f7fa74f;hp=4522eb628d5bdd49e7f9b1c725a2325af034b496;hpb=f63ea68e457f9e2618eac1d3d62227d2b605651b;p=public-inbox.git diff --git a/lib/PublicInbox/SearchMsg.pm b/lib/PublicInbox/SearchMsg.pm index 4522eb62..afba8b1a 100644 --- a/lib/PublicInbox/SearchMsg.pm +++ b/lib/PublicInbox/SearchMsg.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2016 all contributors +# Copyright (C) 2015-2018 all contributors # License: AGPL-3.0+ # based on notmuch, but with no concept of folders, files or flags # @@ -14,7 +14,7 @@ use PublicInbox::Address; sub new { my ($class, $mime) = @_; my $doc = Search::Xapian::Document->new; - $doc->add_term(PublicInbox::Search::xpfx('type') . 'mail'); + $doc->add_term('T' . 'mail'); bless { type => 'mail', doc => $doc, mime => $mime }, $class; } @@ -29,6 +29,22 @@ sub get_val ($$) { Search::Xapian::sortable_unserialise($doc->get_value($col)); } +sub load_expand { + my ($self) = @_; + my $doc = $self->{doc}; + my $data = $doc->get_data or return; + $self->{ts} = get_val($doc, &PublicInbox::Search::TS); + utf8::decode($data); + my ($subj, $from, $refs, $to, $cc, $blob) = split(/\n/, $data); + $self->{subject} = $subj; + $self->{from} = $from; + $self->{references} = $refs; + $self->{to} = $to; + $self->{cc} = $cc; + $self->{blob} = $blob; + $self; +} + sub load_doc { my ($class, $doc) = @_; my $data = $doc->get_data or return; @@ -103,7 +119,7 @@ sub from_name { sub ts { my ($self) = @_; - $self->{ts} ||= eval { str2time($self->mime->header('Date')) } || 0; + $self->{ts} ||= eval { str2time($self->{mime}->header('Date')) } || 0; } sub to_doc_data { @@ -146,36 +162,7 @@ sub mid ($;$) { } } -sub _extract_mid { mid_clean(mid_mime($_[0]->mime)) } - -sub blob { - my ($self, $x40) = @_; - if (defined $x40) { - $self->{blob} = $x40; - } else { - $self->{blob}; - } -} - -sub mime { - my ($self, $mime) = @_; - if (defined $mime) { - $self->{mime} = $mime; - } else { - # TODO load from git - $self->{mime}; - } -} - -sub doc_id { - my ($self, $doc_id) = @_; - if (defined $doc_id) { - $self->{doc_id} = $doc_id; - } else { - # TODO load from xapian - $self->{doc_id}; - } -} +sub _extract_mid { mid_clean(mid_mime($_[0]->{mime})) } sub thread_id { my ($self) = @_; @@ -184,6 +171,7 @@ sub thread_id { $self->{thread} = _get_term_val($self, 'G', qr/\AG/); # *G*roup } +# XXX: consider removing this, we can phrase match subject sub path { my ($self) = @_; my $path = $self->{path};