X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FWwwAtomStream.pm;h=5d32294eec159f58cb9b2ff7153f512c5d0d3b63;hb=45f87867107724371d80a563099ab93eda1d919b;hp=1ed806fd42543fcf4ad650577f8ad369732fbccb;hpb=0821af5f21fdb083020ae2e3e79e4227ef59cd4f;p=public-inbox.git diff --git a/lib/PublicInbox/WwwAtomStream.pm b/lib/PublicInbox/WwwAtomStream.pm index 1ed806fd..5d32294e 100644 --- a/lib/PublicInbox/WwwAtomStream.pm +++ b/lib/PublicInbox/WwwAtomStream.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2020 all contributors +# Copyright (C) 2016-2021 all contributors # License: AGPL-3.0+ # # Atom body stream for HTTP responses @@ -15,7 +15,7 @@ use PublicInbox::MsgTime qw(msg_timestamp); sub new { my ($class, $ctx, $cb) = @_; - $ctx->{feed_base_url} = $ctx->{-inbox}->base_url($ctx->{env}); + $ctx->{feed_base_url} = $ctx->{ibx}->base_url($ctx->{env}); $ctx->{cb} = $cb || \&PublicInbox::GzipFilter::close; $ctx->{emit_header} = 1; bless $ctx, $class; @@ -53,7 +53,7 @@ sub getline { my ($self) = @_; my $cb = $self->{cb} or return; while (my $smsg = $cb->($self)) { - my $eml = $self->{-inbox}->smsg_eml($smsg) or next; + my $eml = $self->{ibx}->smsg_eml($smsg) or next; return $self->translate(feed_entry($self, $smsg, $eml)); } delete $self->{cb}; @@ -82,7 +82,7 @@ sub to_uuid ($) { sub atom_header { my ($ctx, $title) = @_; - my $ibx = $ctx->{-inbox}; + my $ibx = $ctx->{ibx}; my $base_url = $ctx->{feed_base_url}; my $search_q = $ctx->{search_query}; my $self_url = $base_url; @@ -100,7 +100,11 @@ sub atom_header { } else { $title = title_tag($ibx->description); $self_url .= 'new.atom'; - $page_id = "mailto:$ibx->{-primary_address}"; + if (defined(my $addr = $ibx->{-primary_address})) { + $page_id = "mailto:$addr"; + } else { + $page_id = to_uuid($self_url); + } } qq(\n) . qq(header_obj; my $mid = $smsg->{mid}; - my $irt = PublicInbox::View::in_reply_to($hdr); + my $irt = PublicInbox::View::in_reply_to($eml); my $uuid = to_uuid($mid); my $base = $ctx->{feed_base_url}; if (defined $irt) { @@ -130,17 +133,17 @@ sub feed_entry { $irt = ''; } my $href = $base . mid_href($mid) . '/'; - my $updated = feed_updated(msg_timestamp($hdr)); + my $updated = feed_updated(msg_timestamp($eml)); - my $title = $hdr->header('Subject'); + my $title = $eml->header('Subject'); $title = '(no subject)' unless defined $title && $title ne ''; $title = title_tag($title); - my $from = $hdr->header('From') // $hdr->header('Sender') // - $ctx->{-inbox}->{-primary_address}; + my $from = $eml->header('From') // $eml->header('Sender') // + $ctx->{ibx}->{-primary_address}; my ($email) = PublicInbox::Address::emails($from); my $name = ascii_html(join(', ', PublicInbox::Address::names($from))); - $email = ascii_html($email // $ctx->{-inbox}->{-primary_address}); + $email = ascii_html($email // $ctx->{ibx}->{-primary_address}); my $s = delete($ctx->{emit_header}) ? atom_header($ctx, $title) : ''; $s .= "$name$email" . @@ -158,7 +161,8 @@ sub feed_entry { } sub feed_updated { - '' . strftime('%Y-%m-%dT%H:%M:%SZ', gmtime(@_)) . ''; + my ($t) = @_; + '' . strftime('%Y-%m-%dT%H:%M:%SZ', gmtime($t)) . ''; } 1;