]> Sergey Matveev's repositories - public-inbox.git/commitdiff
mda: hoist out mda_filter_adjust
authorEric Wong <e@80x24.org>
Mon, 28 Oct 2019 10:45:22 +0000 (10:45 +0000)
committerEric Wong <e@80x24.org>
Wed, 30 Oct 2019 08:48:17 +0000 (08:48 +0000)
It makes it easier to document the default -mda behavior is
stricter than normal, including "public-inbox-learn ham"

script/public-inbox-mda

index 3ff318c916007f2f19751b51a241ecb22fca2819..71c5d93714de0b77802b4f00cba8410f7c33e01f 100755 (executable)
@@ -75,13 +75,19 @@ if ($spamc) {
 my $mime = PublicInbox::MIME->new(\$str);
 do_exit(0) unless $spam_ok;
 
 my $mime = PublicInbox::MIME->new(\$str);
 do_exit(0) unless $spam_ok;
 
-my $fcfg = $dst->{filter} || '';
-# -mda defaults to the strict base filter
-if ($fcfg eq '') {
-       $dst->{filter} = 'PublicInbox::Filter::Base';
-} elsif ($fcfg eq 'scrub') { # legacy alias, undocumented, remove?
-       $dst->{filter} = 'PublicInbox::Filter::Mirror';
+# -mda defaults to the strict base filter which we won't use anywhere else
+sub mda_filter_adjust ($) {
+       my ($ibx) = @_;
+       my $fcfg = $ibx->{filter} || '';
+       if ($fcfg eq '') {
+               $ibx->{filter} = 'PublicInbox::Filter::Base';
+       } elsif ($fcfg eq 'scrub') { # legacy alias, undocumented, remove?
+               $ibx->{filter} = 'PublicInbox::Filter::Mirror';
+       }
 }
 }
+
+mda_filter_adjust($dst);
+
 my $filter = $dst->filter;
 my $ret = $filter->delivery($mime);
 if (ref($ret) && $ret->isa('Email::MIME')) { # filter altered message
 my $filter = $dst->filter;
 my $ret = $filter->delivery($mime);
 if (ref($ret) && $ret->isa('Email::MIME')) { # filter altered message