- $rv{url} ||= "$url_base/";
- $rv{midurl} = "$url_base/m/";
- $rv{fullurl} = "$url_base/f/";
-
- \%rv;
-}
-
-sub mime_header {
- my ($mime, $name) = @_;
- PublicInbox::Hval->new_oneline($mime->header($name))->raw;
-}
-
-sub feed_date {
- my ($date) = @_;
- my @t = eval { strptime($date) };
-
- scalar(@t) ? POSIX::strftime(DATEFMT, @t) : 0;
-}
-
-# returns 0 (skipped) or 1 (added)
-sub add_to_feed {
- my ($feed_opts, $feed, $add, $git) = @_;
-
- my $mime = do_cat_mail($git, $add) or return 0;
- my $midurl = $feed_opts->{midurl} || 'http://example.com/m/';
- my $fullurl = $feed_opts->{fullurl} || 'http://example.com/f/';
-
- my $mid = $mime->header_obj->header_raw('Message-ID');
- defined $mid or return 0;
- $mid = PublicInbox::Hval->new_msgid($mid);
- my $href = $mid->as_href . '.html';
- my $content = PublicInbox::View->feed_entry($mime, $fullurl . $href);
- defined($content) or return 0;
-
- my $subject = mime_header($mime, 'Subject') or return 0;
-
- my $from = mime_header($mime, 'From') or return 0;
- my @from = Email::Address->parse($from);
- my $name = $from[0]->name;
- defined $name or $name = "";
- my $email = $from[0]->address;
- defined $email or $email = "";