user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 3/4] mda: fix and test some usage problems
  2023-11-11  9:04  6% [PATCH 0/4] support publicinboxImport.dropUniqueUnsubscribe Eric Wong
@ 2023-11-11  9:04  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2023-11-11  9:04 UTC (permalink / raw)
  To: meta

-mda now honors `--help' properly and invocations missing
ORIGINAL_RECIPIENT now fail with EX_NOUSER.

Helped-by: Leah Neukirchen <leah@vuxu.org>
Link: https://public-inbox.org/meta/87msvlguqu.fsf@vuxu.org/
---
 script/public-inbox-mda |  7 ++++++-
 t/mda.t                 | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/script/public-inbox-mda b/script/public-inbox-mda
index 04fd8aad..b2e0908d 100755
--- a/script/public-inbox-mda
+++ b/script/public-inbox-mda
@@ -20,6 +20,10 @@ use PublicInbox::Import;
 local $PublicInbox::Import::DROP_UNIQUE_UNSUB; # does this need a CLI switch?
 GetOptions('precheck!' => \$precheck, 'help|h' => \$show_help) or
 	do { print STDERR $help; exit 1 };
+if ($show_help) {
+	print $help;
+	exit;
+}
 
 my $do_exit = sub {
 	my ($code) = shift;
@@ -59,7 +63,8 @@ if (defined $recipient) {
 if (!scalar(@$dests)) {
 	$dests = PublicInbox::MDA->inboxes_for_list_id($cfg, $eml);
 	if (!scalar(@$dests) && !defined($recipient)) {
-		die "ORIGINAL_RECIPIENT not defined in ENV\n";
+		warn "ORIGINAL_RECIPIENT not defined in ENV\n";
+		$do_exit->(67); # EX_NOUSER
 	}
 	scalar(@$dests) or $do_exit->(67); # EX_NOUSER 5.1.1 user unknown
 }
diff --git a/t/mda.t b/t/mda.t
index 5144f3ca..1d9e237b 100644
--- a/t/mda.t
+++ b/t/mda.t
@@ -82,6 +82,13 @@ die $@ if $@;
 	local $ENV{PI_EMERGENCY} = $faildir;
 	local $ENV{HOME} = $home;
 	local $ENV{ORIGINAL_RECIPIENT} = $addr;
+	ok(run_script([qw(-mda --help)], undef,
+		{ 1 => \my $out, 2 => \my $err }), '-mda --help');
+	like $out, qr/usage:/, 'usage shown w/ --help';
+	ok(!run_script([qw(-mda --bogus)], undef,
+		{ 1 => \$out, 2 => \$err }), '-mda --bogus fails');
+	like $err, qr/usage:/, 'usage shown on bogus switch';
+
 	my $in = <<EOF;
 From: Me <me\@example.com>
 To: You <you\@example.com>
@@ -91,6 +98,17 @@ Subject: hihi
 Date: Thu, 01 Jan 1970 00:00:00 +0000
 
 EOF
+	{
+		local $ENV{PATH} = $main_path;
+		ok(!run_script(['-mda'], { ORIGINAL_RECIPIENT => undef },
+			{ 0 => \$in, 2 => \$err }),
+			'missing ORIGINAL_RECIPIENT fails');
+		is($? >> 8, 67, 'got EX_NOUSER');
+		like $err, qr/\bORIGINAL_RECIPIENT\b/,
+			'ORIGINAL_RECIPIENT noted in stderr';
+		is unlink(glob("$faildir/*/*")), 1, 'unlinked failed message';
+	}
+
 	# ensure successful message delivery
 	{
 		local $ENV{PATH} = $main_path;

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/4] support publicinboxImport.dropUniqueUnsubscribe
@ 2023-11-11  9:04  6% Eric Wong
  2023-11-11  9:04  7% ` [PATCH 3/4] mda: fix and test some usage problems Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2023-11-11  9:04 UTC (permalink / raw)
  To: meta

Patch 2 is the important one in this series to drop unique
tokens from public archives.

I noticed our unsubscribe.milter example was adopted on one of
the lists I'm subscribed to, and didn't want my independent
public archive of that list to get sabotaged by somebody else
unsubscribing me via HTTPS.

Oddly, the rest of the unsubscription process via
unsubscribe.psgi (HTTPS) or mailto: didn't seem configured by
that list I'm subscribed to.  IOW, they're only running
unsubscribe.milter so far and generating List-Unsubscribe
headers which don't work...

1, 3 and 4 fix some small things I noticed while working on 2.

Eric Wong (4):
  learn: fix redundant ham import on dual matches
  mda|learn|watch: support dropUniqueUnsubscribe config
  mda: fix and test some usage problems
  doc: update README.unsubscribe

 Documentation/public-inbox-config.pod | 17 ++++++++
 Documentation/public-inbox-learn.pod  | 19 +++++++++
 Documentation/public-inbox-mda.pod    | 18 +++++++-
 Documentation/public-inbox-watch.pod  |  6 ++-
 examples/README.unsubscribe           |  9 ++--
 lib/PublicInbox/Import.pm             | 27 ++++++++++++
 lib/PublicInbox/LeiToMail.pm          |  6 +++
 lib/PublicInbox/Watch.pm              |  1 +
 script/public-inbox-learn             |  7 +++-
 script/public-inbox-mda               | 11 ++++-
 script/public-inbox-watch             |  2 +
 t/lei-import.t                        | 48 +++++++++++++++++++++-
 t/mda.t                               | 59 +++++++++++++++++++++++++--
 t/watch_maildir.t                     | 30 ++++++++++++--
 14 files changed, 242 insertions(+), 18 deletions(-)

^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2023-11-11  9:04  6% [PATCH 0/4] support publicinboxImport.dropUniqueUnsubscribe Eric Wong
2023-11-11  9:04  7% ` [PATCH 3/4] mda: fix and test some usage problems Eric Wong

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