user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [RFC PATCH] watchmaildir: support multiple watchheader values
@ 2020-04-12  4:44 Kyle Meyer
  2020-04-12 21:59 ` Eric Wong
  0 siblings, 1 reply; 8+ messages in thread
From: Kyle Meyer @ 2020-04-12  4:44 UTC (permalink / raw)
  To: meta; +Cc: Kyle Meyer

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.

[1] https://public-inbox.org/meta/20191010085118.r3amey4cayazfycb@dcvr/
---

  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/Config.pm             | 4 ++--
 lib/PublicInbox/WatchMaildir.pm       | 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:<test.example.com>
 
 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/Config.pm b/lib/PublicInbox/Config.pm
index 917939ca..458f29b2 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -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/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm
index e2024640..bdaacf62 100644
--- a/lib/PublicInbox/WatchMaildir.pm
+++ b/lib/PublicInbox/WatchMaildir.pm
@@ -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
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-04-20 13:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-12  4:44 [RFC PATCH] watchmaildir: support multiple watchheader values Kyle Meyer
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

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).