X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FWwwAtomStream.pm;h=fd861d45b549586962aed303760322a2b07887aa;hb=9bd675d33ad1e49bd2ebe12a1d216216e61380de;hp=b9c7468f18920d05025979c5dad6f1e547fddc21;hpb=2a5b77c0cdd9bb1f726fd05b01d3095b029367ac;p=public-inbox.git diff --git a/lib/PublicInbox/WwwAtomStream.pm b/lib/PublicInbox/WwwAtomStream.pm index b9c7468f..fd861d45 100644 --- a/lib/PublicInbox/WwwAtomStream.pm +++ b/lib/PublicInbox/WwwAtomStream.pm @@ -1,17 +1,20 @@ -# Copyright (C) 2016 all contributors +# Copyright (C) 2016-2019 all contributors # License: AGPL-3.0+ # # Atom body stream for which yields getline+close methods +# public-inbox-httpd favors "getline" response bodies to take a +# "pull"-based approach to feeding slow clients (as opposed to a +# more common "push" model) package PublicInbox::WwwAtomStream; use strict; use warnings; use POSIX qw(strftime); -use Date::Parse qw(str2time); use Digest::SHA qw(sha1_hex); use PublicInbox::Address; use PublicInbox::Hval qw(ascii_html); use PublicInbox::MID qw/mid_clean mid_escape/; +use PublicInbox::MsgTime qw(msg_timestamp); # called by PSGI server after getline: sub close {} @@ -33,8 +36,8 @@ sub response { sub getline { my ($self) = @_; if (my $middle = $self->{cb}) { - my $mime = $middle->(); - return feed_entry($self, $mime) if $mime; + my $smsg = $middle->(); + return feed_entry($self, $smsg) if $smsg; } delete $self->{cb} ? '' : undef; } @@ -92,10 +95,11 @@ sub mid2uuid ($) { # returns undef or string sub feed_entry { - my ($self, $mime) = @_; + my ($self, $smsg) = @_; my $ctx = $self->{ctx}; + my $mime = $smsg->{mime}; my $hdr = $mime->header_obj; - my $mid = mid_clean($hdr->header_raw('Message-ID')); + my $mid = $smsg->mid; my $irt = PublicInbox::View::in_reply_to($hdr); my $uuid = mid2uuid($mid); my $base = $ctx->{feed_base_url}; @@ -108,8 +112,7 @@ sub feed_entry { $irt = ''; } my $href = $base . mid_escape($mid) . '/'; - my $date = $hdr->header('Date'); - my $t = eval { str2time($date) } if defined $date; + my $t = msg_timestamp($hdr); my @t = gmtime(defined $t ? $t : time); my $updated = feed_updated(@t); @@ -129,13 +132,13 @@ sub feed_entry { } $s .= "$name$email" . "$title$updated" . + qq(). + "$uuid$irt" . qq{} . qq{} . qq() . - PublicInbox::View::multipart_text_as_html($mime, $href) . - '' . - qq!!. - "$uuid$irt"; + PublicInbox::View::multipart_text_as_html($mime, $href, $ctx) . + ''; } sub feed_updated {