- my $feed_opts = $ctx->{feed_opts};
- unless ($feed_opts) {
- require PublicInbox::Feed; # FIXME: gross
- $feed_opts = PublicInbox::Feed::get_feedopts($ctx);
- $ctx->{feed_opts} = $feed_opts;
- }
- my $base = $feed_opts->{url};
- my $mid = mid_clean($header_obj->header('Message-ID'));
- $mid = uri_escape_utf8($mid);
- my @archived_at = $header_obj->header('Archived-At');
- push @archived_at, "<$base$mid/>";
- $header_obj->header_set('Archived-At', @archived_at);
- $header_obj->header_set('List-Archive', "<$base>");
- $header_obj->header_set('List-Post', "<mailto:$feed_opts->{id_addr}>");
-
- my $buf = $header_obj->as_string;
- unless ($buf =~ /\AFrom /) {
- $fh->write("From mboxrd\@z Thu Jan 1 00:00:00 1970\n");
+ my $ibx = $ctx->{-inbox};
+ my $base = $ctx->{base_url};
+ $mid = $ctx->{mid} unless defined $mid;
+ $mid = mid_escape($mid);
+ my @append = (
+ 'Archived-At', "<$base$mid/>",
+ 'List-Archive', "<$base>",
+ 'List-Post', "<mailto:$ibx->{-primary_address}>",
+ );
+ my $crlf = $header_obj->crlf;
+ my $buf = "From mboxrd\@z Thu Jan 1 00:00:00 1970\n" .
+ $header_obj->as_string;
+ for (my $i = 0; $i < @append; $i += 2) {
+ my $k = $append[$i];
+ my $v = $append[$i + 1];
+ my @v = $header_obj->header($k);
+ foreach (@v) {
+ if ($v eq $_) {
+ $v = undef;
+ last;
+ }
+ }
+ $buf .= "$k: $v$crlf" if defined $v;