]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WwwAtomStream.pm
www: fix unindexed v1 inboxes w/ public-inbox-httpd
[public-inbox.git] / lib / PublicInbox / WwwAtomStream.pm
index 912f860ececa8e16e13a7782ae96b625d4d78bb7..7b7047ac26d39e9647d3866d3a65801ca2dbaf54 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Atom body stream for HTTP responses
@@ -28,7 +28,7 @@ sub async_next ($) {
                if (my $smsg = $ctx->{smsg} = $ctx->{cb}->($ctx)) {
                        $ctx->smsg_blob($smsg);
                } else {
-                       $ctx->{http_out}->write($ctx->translate('</feed>'));
+                       $ctx->write('</feed>');
                        $ctx->close;
                }
        };
@@ -38,7 +38,8 @@ sub async_next ($) {
 sub async_eml { # for async_blob_cb
        my ($ctx, $eml) = @_;
        my $smsg = delete $ctx->{smsg};
-       $ctx->{http_out}->write($ctx->translate(feed_entry($ctx, $smsg, $eml)))
+       $smsg->{mid} // $smsg->populate($eml);
+       $ctx->write(feed_entry($ctx, $smsg, $eml));
 }
 
 sub response {
@@ -100,7 +101,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(<?xml version="1.0" encoding="us-ascii"?>\n) .
        qq(<feed\nxmlns="http://www.w3.org/2005/Atom"\n) .
@@ -157,7 +162,8 @@ sub feed_entry {
 }
 
 sub feed_updated {
-       '<updated>' . strftime('%Y-%m-%dT%H:%M:%SZ', gmtime(@_)) . '</updated>';
+       my ($t) = @_;
+       '<updated>' . strftime('%Y-%m-%dT%H:%M:%SZ', gmtime($t)) . '</updated>';
 }
 
 1;