From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS11403 64.147.108.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from pb-smtp2.pobox.com (pb-smtp2.pobox.com [64.147.108.71]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 7C7AA1F5AD for ; Sun, 12 Apr 2020 04:45:04 +0000 (UTC) Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 2B5BF43A60; Sun, 12 Apr 2020 00:45:03 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; s=sasl; bh=20es3Z3SPEsU0HhEzN8Vs+Gq61g=; b=yhN7eezAtUybg3WaXYTa kL5mh7ElvZdhIsJA16c5KE0Tfh7RsgvSirjjRtieVxwJh0hrFwv7EHAhfOfEEE4M 0IK9I3dUkpOrdxWVwnGVcPPFUL+/pda9+1vXqz/Zl1heV+pcvM3y2cuafqhipafv OvOz0KDe8su291d1VOda8C0= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 0E4C343A5E; Sun, 12 Apr 2020 00:45:03 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:cc:subject:date:message-id:mime-version:content-transfer-encoding; s=mesmtp; bh=QTvxsGh0qghoSk54GG9a4+4G+4s49zkQdcBWIFAIEm0=; b=S4Ltr4VHyZzBB4KOPu5zCwQUTXizx9wBtoOh3H5mXjCp5kmRNgNymq3+QduYoqEJ7s73KcUTufIJKcE19spV7ReHODbF8worMyR3qnRN2VF2fW6D4U/oUrX/klfT8vFAI7dr+0Vuxo7wH1kM7IUP0g4i735jflYMa9G8dsobXtE= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 009D743A58; Sun, 12 Apr 2020 00:45:01 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: meta@public-inbox.org Cc: Kyle Meyer Subject: [RFC PATCH] watchmaildir: support multiple watchheader values Date: Sun, 12 Apr 2020 00:44:52 -0400 Message-Id: <20200412044452.7524-1-kyle@kyleam.com> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 X-Pobox-Relay-ID: 5F05C7A2-7C78-11EA-9371-D1361DBA3BAF-24757444!pb-smtp2.pobox.com Content-Transfer-Encoding: quoted-printable List-Id: The watchheader key supports only a single value. In discussion [1] of 8d3e3bd8 (doc: explain publicinbox..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 users watchheader =3D List-Id: =20 If specified, L 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. =20 Default: none; only for L users =20 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 =3D {}; =20 foreach my $k (qw(inboxdir filter newsgroup - watch watchheader httpbackendmax + watch httpbackendmax replyto feedmax nntpserver indexlevel)) { my $v =3D $self->{"$pfx.$k"}; $ibx->{$k} =3D $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 =3D $self->{"$pfx.$k"})) { $ibx->{$k} =3D _array($v); } diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaild= ir.pm index e2024640..bdaacf62 100644 --- a/lib/PublicInbox/WatchMaildir.pm +++ b/lib/PublicInbox/WatchMaildir.pm @@ -59,9 +59,11 @@ sub new { my $watch =3D $ibx->{watch} or return; if (is_maildir($watch)) { my $watch_hdrs =3D []; - if (my $wh =3D $ibx->{watchheader}) { - my ($k, $v) =3D split(/:/, $wh, 2); - push @$watch_hdrs, [ $k, qr/\Q$v\E/ ]; + if (my $whs =3D $ibx->{watchheader}) { + for (@$whs) { + my ($k, $v) =3D split(/:/, $_, 2); + push @$watch_hdrs, [ $k, qr/\Q$v\E/ ]; + } } if (my $list_ids =3D $ibx->{listid}) { for (@$list_ids) { base-commit: d7270ec79e6347eb1c35ebcdc197e887bb4ef075 --=20 2.26.0