From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] www+nntp: deal with lack of addresses for ->ALL
Date: Wed, 9 Dec 2020 23:33:00 +0000 [thread overview]
Message-ID: <20201209233300.16139-1-e@80x24.org> (raw)
Since extindex is an amalgamation of several inboxes, discerning
an appropriate address for List-Post: would be expensive and
most likely unnecessary. Some legacy/historical inboxes may
have no active address, either, so don't attempt to set the
List-Post header if no addresses are configured.
---
lib/PublicInbox/Mbox.pm | 13 +++++--------
lib/PublicInbox/NNTP.pm | 5 +++--
lib/PublicInbox/WwwStream.pm | 9 +++++----
3 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm
index 64de8c72..c88350c9 100644
--- a/lib/PublicInbox/Mbox.pm
+++ b/lib/PublicInbox/Mbox.pm
@@ -106,7 +106,6 @@ sub msg_hdr ($$;$) {
my @append = (
'Archived-At', "<$base$mid/>",
'List-Archive', "<$base>",
- 'List-Post', "<mailto:$ibx->{-primary_address}>",
);
my $crlf = $header_obj->crlf;
my $buf = $header_obj->as_string;
@@ -118,13 +117,11 @@ sub msg_hdr ($$;$) {
my $k = $append[$i];
my $v = $append[$i + 1];
my @v = $header_obj->header_raw($k);
- foreach (@v) {
- if ($v eq $_) {
- $v = undef;
- last;
- }
- }
- $buf .= "$k: $v$crlf" if defined $v;
+ $buf .= "$k: $v$crlf" if !grep(/\A\Q$v\E\z/, @v);
+ }
+ my $post_addr = $ibx->{-primary_address};
+ if ($post_addr && $header_obj->header_raw('List-Post')) {
+ $buf .= "List-Post: <mailto:$post_addr>$crlf";
}
$buf .= $crlf;
}
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 0b43cdbc..097fdb84 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -487,8 +487,9 @@ sub set_nntp_headers ($$) {
# *something* here is required for leafnode, try to follow
# RFC 5536 3.1.5...
$hdr->header_set('Path', $server_name . '!not-for-mail');
-
- header_append($hdr, 'List-Post', "<mailto:$ibx->{-primary_address}>");
+ if (my $post_addr = $ibx->{-primary_address}) {
+ header_append($hdr, 'List-Post', "<mailto:$post_addr>");
+ }
if (my $url = $ibx->base_url) {
$mid = mid_escape($mid);
header_append($hdr, 'Archived-At', "<$url$mid/>");
diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm
index 34e12435..66e34a12 100644
--- a/lib/PublicInbox/WwwStream.pm
+++ b/lib/PublicInbox/WwwStream.pm
@@ -143,10 +143,10 @@ EOF
}
$urls .= "\n" . join('', map { "\tgit clone --mirror $_\n" } @urls);
- my $addrs = $ibx->{address};
- $addrs = join(' ', @$addrs) if ref($addrs) eq 'ARRAY';
- my $v = defined $max ? '-V2' : '-V1';
- $urls .= <<EOF;
+ if (my $addrs = $ibx->{address}) {
+ $addrs = join(' ', @$addrs) if ref($addrs) eq 'ARRAY';
+ my $v = defined $max ? '-V2' : '-V1';
+ $urls .= <<EOF;
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
@@ -154,6 +154,7 @@ EOF
$addrs
public-inbox-index $dir
EOF
+ }
my $cfg_link = ($ctx->{-upfx} // '').'_/text/config/raw';
$urls .= <<EOF;
reply other threads:[~2020-12-09 23:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201209233300.16139-1-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).