]> Sergey Matveev's repositories - public-inbox.git/commitdiff
wwwatomstream: convert callers to use smsg_eml
authorEric Wong <e@yhbt.net>
Mon, 1 Jun 2020 10:06:46 +0000 (10:06 +0000)
committerEric Wong <e@yhbt.net>
Wed, 3 Jun 2020 04:04:21 +0000 (04:04 +0000)
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.

lib/PublicInbox/Feed.pm
lib/PublicInbox/SearchView.pm
lib/PublicInbox/WwwAtomStream.pm

index e64628be830a34675b4c0c01462ec615af045329..b770a35077c2f0194db5472a55756f59433a4169 100644 (file)
@@ -12,7 +12,7 @@ use PublicInbox::Smsg; # this loads w/o Search::Xapian
 sub generate_i {
        my ($ctx) = @_;
        while (my $smsg = shift @{$ctx->{msgs}}) {
-               $ctx->{-inbox}->smsg_mime($smsg) and return $smsg;
+               return $smsg;
        }
 }
 
index 4336e4d9b2d83ed289521450b0e958e0b1f762d0..249cf53926df75eb6ec22aa91ca1525b62c7803f 100644 (file)
@@ -340,7 +340,7 @@ sub adump_i {
                my $smsg = eval {
                        PublicInbox::Smsg::from_mitem($mi, $ctx->{srch});
                } or next;
-               $ctx->{-inbox}->smsg_mime($smsg) and return $smsg;
+               return $smsg;
        }
 }
 
index c3fbb1a7cef589479f55860474390a7a3b3e5687..6ed0cb212d6d790d5b9c4d8ea142b3052f5379c4 100644 (file)
@@ -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>';
 }