about summary refs log tree commit homepage
path: root/lib/PublicInbox/WwwAtomStream.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-01 10:06:46 +0000
committerEric Wong <e@yhbt.net>2020-06-03 04:04:21 +0000
commitaae8eb6de7b8ed4b1370971e91802b12da7f81aa (patch)
tree69b1d4e1f6993098e3a35ab8d6f0a21e104044ab /lib/PublicInbox/WwwAtomStream.pm
parent30ac717281ae224a9c117361ca941818adc69cf3 (diff)
downloadpublic-inbox-aae8eb6de7b8ed4b1370971e91802b12da7f81aa.tar.gz
We can simplify WwwAtomStream callbacks by performing ->smsg_eml
calls in the `feed_entry' sub itself.  This simplifies callers,
by reducing the number of places which can load an Eml object
into memory.
Diffstat (limited to 'lib/PublicInbox/WwwAtomStream.pm')
-rw-r--r--lib/PublicInbox/WwwAtomStream.pm9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/PublicInbox/WwwAtomStream.pm b/lib/PublicInbox/WwwAtomStream.pm
index c3fbb1a7..6ed0cb21 100644
--- a/lib/PublicInbox/WwwAtomStream.pm
+++ b/lib/PublicInbox/WwwAtomStream.pm
@@ -12,6 +12,7 @@ use warnings;
 use POSIX qw(strftime);
 use Digest::SHA qw(sha1_hex);
 use PublicInbox::Address;
+use PublicInbox::MID qw(mids);
 use PublicInbox::Hval qw(ascii_html mid_href);
 use PublicInbox::MsgTime qw(msg_timestamp);
 
@@ -99,9 +100,9 @@ sub atom_header {
 sub feed_entry {
         my ($self, $smsg) = @_;
         my $ctx = $self->{ctx};
-        my $mid = $smsg->mid; # may extract Message-ID from {mime}
-        my $mime = delete $smsg->{mime};
-        my $hdr = $mime->header_obj;
+        my $eml = $ctx->{-inbox}->smsg_eml($smsg) or return '';
+        my $hdr = $eml->header_obj;
+        my $mid = $smsg->{mid} // mids($hdr)->[0];
         my $irt = PublicInbox::View::in_reply_to($hdr);
         my $uuid = to_uuid($mid);
         my $base = $ctx->{feed_base_url};
@@ -141,7 +142,7 @@ sub feed_entry {
                 qq(<pre\nstyle="white-space:pre-wrap">);
         $ctx->{obuf} = \$s;
         $ctx->{mhref} = $href;
-        PublicInbox::View::multipart_text_as_html($mime, $ctx);
+        PublicInbox::View::multipart_text_as_html($eml, $ctx);
         delete $ctx->{obuf};
         $s .= '</pre></div></content></entry>';
 }