about summary refs log tree commit homepage
path: root/lib/PublicInbox/WwwAtomStream.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-07-05 23:27:35 +0000
committerEric Wong <e@yhbt.net>2020-07-06 20:01:15 +0000
commit703f4c711bfe82e94c9b760f73ed89cfba3d00fc (patch)
tree99659b8574515bb9abe7fafc77fd3ba80dc4cb1c /lib/PublicInbox/WwwAtomStream.pm
parentc6eb69349c32d9a749a5878364c427745bce3d1b (diff)
downloadpublic-inbox-703f4c711bfe82e94c9b760f73ed89cfba3d00fc.tar.gz
No need to deepen our object graph, here.
Diffstat (limited to 'lib/PublicInbox/WwwAtomStream.pm')
-rw-r--r--lib/PublicInbox/WwwAtomStream.pm17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/PublicInbox/WwwAtomStream.pm b/lib/PublicInbox/WwwAtomStream.pm
index 35b536c1..9f322d38 100644
--- a/lib/PublicInbox/WwwAtomStream.pm
+++ b/lib/PublicInbox/WwwAtomStream.pm
@@ -22,15 +22,17 @@ sub close {}
 sub new {
         my ($class, $ctx, $cb) = @_;
         $ctx->{feed_base_url} = $ctx->{-inbox}->base_url($ctx->{env});
-        bless { cb => $cb || \&close, ctx => $ctx, emit_header => 1 }, $class;
+        $ctx->{cb} = $cb || \&close;
+        $ctx->{emit_header} = 1;
+        bless $ctx, $class;
 }
 
 sub response {
         my ($class, $ctx, $code, $cb) = @_;
         my $h = [ 'Content-Type' => 'application/atom+xml' ];
-        my $self = $class->new($ctx, $cb);
-        $self->{gzf} = gzf_maybe($h, $ctx->{env});
-        [ $code, $h, $self ]
+        $class->new($ctx, $cb);
+        $ctx->{gzf} = gzf_maybe($h, $ctx->{env});
+        [ $code, $h, $ctx ]
 }
 
 # called once for each message by PSGI server
@@ -38,7 +40,7 @@ sub getline {
         my ($self) = @_;
         my $buf = do {
                 if (my $middle = $self->{cb}) {
-                        my $smsg = $middle->($self->{ctx});
+                        my $smsg = $middle->($self);
                         feed_entry($self, $smsg) if $smsg;
                 }
         } // (delete($self->{cb}) ? '</feed>' : undef);
@@ -106,8 +108,7 @@ sub atom_header {
 
 # returns undef or string
 sub feed_entry {
-        my ($self, $smsg) = @_;
-        my $ctx = $self->{ctx};
+        my ($ctx, $smsg) = @_;
         my $eml = $ctx->{-inbox}->smsg_eml($smsg) or return '';
         my $hdr = $eml->header_obj;
         my $mid = $smsg->{mid};
@@ -136,7 +137,7 @@ sub feed_entry {
         $email = ascii_html($email);
 
         my $s = '';
-        if (delete $self->{emit_header}) {
+        if (delete $ctx->{emit_header}) {
                 $s .= atom_header($ctx, $title);
         }
         $s .= "<entry><author><name>$name</name><email>$email</email>" .