]> Sergey Matveev's repositories - public-inbox.git/blobdiff - script/public-inbox-mda
drop dependency on File::Path::Expand
[public-inbox.git] / script / public-inbox-mda
index 8e224a50858a4fbd7846f6519febf75d58eea890..84219ac3c2531dcd9cbc98800b7e42f673d6ed2a 100755 (executable)
@@ -9,8 +9,8 @@ my $usage = 'public-inbox-mda < rfc2822_message';
 
 use Email::Filter;
 use Email::MIME;
-use Email::Address;
-use File::Path::Expand qw/expand_filename/;
+use Email::MIME::ContentType;
+$Email::MIME::ContentType::STRICT_PARAMS = 0; # user input is imperfect
 use IPC::Run qw(run);
 use PublicInbox::MDA;
 use PublicInbox::Filter;
@@ -21,8 +21,7 @@ use PublicInbox::Git;
 # n.b: hopefully we can setup the emergency path without bailing due to
 # user error, we really want to setup the emergency destination ASAP
 # in case there's bugs in our code or user error.
-my $emergency = $ENV{PI_EMERGENCY} || '~/.public-inbox/emergency/';
-$emergency = expand_filename($emergency);
+my $emergency = $ENV{PI_EMERGENCY} || "$ENV{HOME}/.public-inbox/emergency/";
 
 # this reads the message from stdin
 my $filter = Email::Filter->new(emergency => $emergency);
@@ -49,7 +48,7 @@ if (PublicInbox::MDA->precheck($filter, $dst->{address}) &&
        } elsif ($fcfg eq 'scrub') {
                $filter_arg = undef; # the default for legacy versions
        } else {
-               warn "publicinbox.$dst->{inbox}.filter=$fcfg invalid\n";
+               warn "publicinbox.$dst->{name}.filter=$fcfg invalid\n";
                warn "must be either 'scrub' or 'reject' (the default)\n";
        }
 
@@ -65,7 +64,7 @@ if (PublicInbox::MDA->precheck($filter, $dst->{address}) &&
                        };
                        my $git = PublicInbox::Git->new($main_repo);
                        my $im = PublicInbox::Import->new($git,
-                                               $dst->{inbox}, $recipient);
+                                               $dst->{name}, $recipient);
                        if (defined $im->add($msg)) {
                                $im->done;
                                $filter->ignore; # exits