user/dev discussion of public-inbox itself
 help / color / Atom feed
From: Kyle Meyer <>
Cc: Kyle Meyer <>
Subject: [RFC PATCH] watchmaildir: support multiple watchheader values
Date: Sun, 12 Apr 2020 00:44:52 -0400
Message-ID: <> (raw)

The watchheader key supports only a single value.  In discussion [1]
of 8d3e3bd8 (doc: explain publicinbox.<name>.watchheader, 2019-10-09),
two concerns were raised about supporting multiple watchheader values:

  * doing so would invite confusion about whether the acceptance
    condition is "all" or "any"

  * it's not clear there's a need

The second point seems to be the crucial one because, provided there
is a need, the first can be addressed with documentation (as already
done for listid, which accepts the message if there are any matches).

Here is one scenario where support for matching multiple headers would
be convenient.  Someone wants to set up public-inbox archives for some
small projects but does _not_ want to run mailing lists for them,
instead allowing others to follow the project by any of the pull
mechanisms.  Using a common underlying address, an address alias for
each project is set up via a third-party email provider, with messages
for each alias being exposed as a separate public-inbox archive.

In this scenario, if all messages are downloaded to a common maildir,
the problem with using watchheader to match the project address is
that the address may be in either the To: or Cc: header.  One way to
avoid this issue would be to filter things upstream so that messages
for different projects got to different maildirs, ideally in a way
that duplicates any cross-posted messages in each maildir.

Teach watchheader to support multiple values, avoiding the need to
direct message with no List-ID to separate maildirs.


  I'm not entirely convinced that the above provides a compelling
  reason to make this change, but I think it's worth considering if it
  makes it easier for some to set up archives for their projects
  without setting up mailings lists.  Thoughts?

  (If this ends up being a direction we decide to go, I'd be happy to
  work on adding tests to this patch.)

 Documentation/public-inbox-config.pod | 3 ++-
 lib/PublicInbox/             | 4 ++--
 lib/PublicInbox/       | 8 +++++---
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/Documentation/public-inbox-config.pod b/Documentation/public-inbox-config.pod
index 53926ef4..f9871d4b 100644
--- a/Documentation/public-inbox-config.pod
+++ b/Documentation/public-inbox-config.pod
@@ -88,7 +88,8 @@ Default: none; only for L<public-inbox-watch(1)> users
 		watchheader = List-Id:<>
 If specified, L<public-inbox-watch(1)> will only process mail matching
-the given header.  Multiple values are not currently supported.
+the given header.  If specified multiple times, mail will be processed
+if it matches any of the values.
 Default: none; only for L<public-inbox-watch(1)> users
diff --git a/lib/PublicInbox/ b/lib/PublicInbox/
index 917939ca..458f29b2 100644
--- a/lib/PublicInbox/
+++ b/lib/PublicInbox/
@@ -367,7 +367,7 @@ sub _fill {
 	my $ibx = {};
 	foreach my $k (qw(inboxdir filter newsgroup
-			watch watchheader httpbackendmax
+			watch httpbackendmax
 			replyto feedmax nntpserver indexlevel)) {
 		my $v = $self->{"$pfx.$k"};
 		$ibx->{$k} = $v if defined $v;
@@ -388,7 +388,7 @@ sub _fill {
 	# TODO: more arrays, we should support multi-value for
 	# more things to encourage decentralization
 	foreach my $k (qw(address altid nntpmirror coderepo hide listid url
-			infourl)) {
+			infourl watchheader)) {
 		if (defined(my $v = $self->{"$pfx.$k"})) {
 			$ibx->{$k} = _array($v);
diff --git a/lib/PublicInbox/ b/lib/PublicInbox/
index e2024640..bdaacf62 100644
--- a/lib/PublicInbox/
+++ b/lib/PublicInbox/
@@ -59,9 +59,11 @@ sub new {
 		my $watch = $ibx->{watch} or return;
 		if (is_maildir($watch)) {
 			my $watch_hdrs = [];
-			if (my $wh = $ibx->{watchheader}) {
-				my ($k, $v) = split(/:/, $wh, 2);
-				push @$watch_hdrs, [ $k, qr/\Q$v\E/ ];
+			if (my $whs = $ibx->{watchheader}) {
+				for (@$whs) {
+					my ($k, $v) = split(/:/, $_, 2);
+					push @$watch_hdrs, [ $k, qr/\Q$v\E/ ];
+				}
 			if (my $list_ids = $ibx->{listid}) {
 				for (@$list_ids) {

base-commit: d7270ec79e6347eb1c35ebcdc197e887bb4ef075

             reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-12  4:44 Kyle Meyer [this message]
2020-04-12 21:59 ` Eric Wong
2020-04-20  0:13   ` [PATCH v2] " Kyle Meyer
2020-04-20  0:45     ` Eric Wong
2020-04-20  1:13       ` Kyle Meyer
2020-04-20  1:32         ` Eric Wong
2020-04-20  7:05           ` [PATCH] doc: HACKING: add a bit about faster testing Eric Wong
2020-04-20 13:26             ` Kyle Meyer

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:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Example config snippet for mirrors

Newsgroups are available over NNTP:

 note: .onion URLs require Tor:

AGPL code for this site: git clone