]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WwwAtomStream.pm
www*stream: favor \&close instead of *close
[public-inbox.git] / lib / PublicInbox / WwwAtomStream.pm
index 05659f1fad7e2355cdd3052f1e597daebee54449..cb7ffe353f54838ed2d9559bd0ac43113096adef 100644 (file)
@@ -13,7 +13,7 @@ use POSIX qw(strftime);
 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::MID qw(mid_escape);
 use PublicInbox::MsgTime qw(msg_timestamp);
 
 # called by PSGI server after getline:
@@ -23,7 +23,7 @@ sub new {
        my ($class, $ctx, $cb) = @_;
        $ctx->{emit_header} = 1;
        $ctx->{feed_base_url} = $ctx->{-inbox}->base_url($ctx->{env});
-       bless { cb => $cb || *close, ctx => $ctx }, $class;
+       bless { cb => $cb || \&close, ctx => $ctx }, $class;
 }
 
 sub response {
@@ -36,7 +36,7 @@ sub response {
 sub getline {
        my ($self) = @_;
        if (my $middle = $self->{cb}) {
-               my $smsg = $middle->();
+               my $smsg = $middle->($self->{ctx});
                return feed_entry($self, $smsg) if $smsg;
        }
        delete $self->{cb} ? '</feed>' : undef;
@@ -84,7 +84,7 @@ sub atom_header {
                $self_url .= 'new.atom';
                $page_id = "mailto:$ibx->{-primary_address}";
        }
-       my $mtime = (stat($ibx->{mainrepo}))[9] || time;
+       my $mtime = (stat($ibx->{inboxdir}))[9] || time;
 
        qq(<?xml version="1.0" encoding="us-ascii"?>\n) .
        qq(<feed\nxmlns="http://www.w3.org/2005/Atom"\n) .
@@ -101,9 +101,9 @@ sub atom_header {
 sub feed_entry {
        my ($self, $smsg) = @_;
        my $ctx = $self->{ctx};
-       my $mime = $smsg->{mime};
+       my $mid = $smsg->mid; # may extract Message-ID from {mime}
+       my $mime = delete $smsg->{mime};
        my $hdr = $mime->header_obj;
-       my $mid = $smsg->mid;
        my $irt = PublicInbox::View::in_reply_to($hdr);
        my $uuid = to_uuid($mid);
        my $base = $ctx->{feed_base_url};