]> 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 83984d37e1813525f621a72afe9a09dc67079706..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;
@@ -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};