use PublicInbox::MID qw/mid_clean mid_mime/;
use PublicInbox::Address;
use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp);
+use Time::Local qw(timegm);
sub new {
my ($class, $mime) = @_;
my $doc = Search::Xapian::Document->new;
- $doc->add_boolean_term('T' . 'mail');
-
- bless { type => 'mail', doc => $doc, mime => $mime }, $class;
+ bless { doc => $doc, mime => $mime }, $class;
}
sub wrap {
$self->cc,
$oid,
$mid0,
- $self->ds,
- $self->{bytes},
- $self->{lines}
+ $self->{bytes} || '',
+ $self->{lines} || ''
);
}
$self->{blob},
$self->{mid},
- $self->{ds},
$self->{bytes},
$self->{lines}
) = split(/\n/, $_[1]);
my ($self) = @_;
my $doc = $self->{doc};
my $data = $doc->get_data or return;
- $self->{ts} = get_val($doc, &PublicInbox::Search::TS);
+ $self->{ts} = get_val($doc, PublicInbox::Search::TS());
+ my $dt = get_val($doc, PublicInbox::Search::DT());
+ my ($yyyy, $mon, $dd, $hh, $mm, $ss) = unpack('A4A2A2A2A2A2', $dt);
+ $self->{ds} = timegm($ss, $mm, $hh, $dd, $mon - 1, $yyyy);
utf8::decode($data);
load_from_data($self, $data);
$self;
# :bytes and :lines metadata in RFC 3977
sub bytes ($) { $_[0]->{bytes} }
sub lines ($) { $_[0]->{lines} }
-sub num ($) { $_[0]->{num} ||= _get_term_val($_[0], 'XNUM', qr/\AXNUM/) }
sub __hdr ($$) {
my ($self, $field) = @_;
my $mime = $self->{mime} or return;
$val = $mime->header($field);
$val = '' unless defined $val;
- $val =~ tr/\n/ /;
+ $val =~ tr/\t\n/ /;
$val =~ tr/\r//d;
$self->{$field} = $val;
}
sub _extract_mid { mid_clean(mid_mime($_[0]->{mime})) }
-sub thread_id {
- my ($self) = @_;
- my $tid = $self->{thread};
- return $tid if defined $tid;
- $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};
- return $path if defined $path;
- $self->{path} = _get_term_val($self, 'XPATH', qr/\AXPATH/); # path
-}
-
-sub type {
- my ($self) = @_;
- my $type = $self->{type};
- return $type if defined $type;
- $self->{type} = _get_term_val($self, 'T', qr/\AT/);
-}
-
1;