[Bps-public-commit] app-wsgetmail branch fix-and-document-command_timeout created. dcb08514484b789556d628f758b8f4be2846d130

BPS Git Server git at git.bestpractical.com
Wed Apr 20 22:34:21 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "app-wsgetmail".

The branch, fix-and-document-command_timeout has been created
        at  dcb08514484b789556d628f758b8f4be2846d130 (commit)

- Log -----------------------------------------------------------------
commit dcb08514484b789556d628f758b8f4be2846d130
Author: Blaine Motsinger <blaine at bestpractical.com>
Date:   Wed Apr 20 17:28:52 2022 -0500

    Correct indent spacing in MS365.pm

diff --git a/lib/App/wsgetmail/MS365.pm b/lib/App/wsgetmail/MS365.pm
index 49ca0d1..f734151 100644
--- a/lib/App/wsgetmail/MS365.pm
+++ b/lib/App/wsgetmail/MS365.pm
@@ -227,7 +227,7 @@ has _next_fetch_url => (
 
 my @config_fields = qw(client_id tenant_id username user_password global_access secret folder post_fetch_action debug);
 around BUILDARGS => sub {
-  my ( $orig, $class, $config ) = @_;
+    my ( $orig, $class, $config ) = @_;
 
     my $attributes = {
         map {
@@ -236,7 +236,7 @@ around BUILDARGS => sub {
         @config_fields
     };
 
-  return $class->$orig($attributes);
+    return $class->$orig($attributes);
 };
 
 

commit e371d7957e956fd972aef6a5e18d1ce2338bbc29
Author: Blaine Motsinger <blaine at bestpractical.com>
Date:   Wed Apr 20 17:07:13 2022 -0500

    Fix default values for attributes
    
    Moo runs the default sub for an attribute if it's not set at build
    time.  In the example of command_timeout, the default sub should
    be setting it to 30 if it's not defined in the config.  If it is
    defined in the config, it should use that instead.
    
    As it's written, if an attribute (command_timeout) doesn't exist
    in the config, BUILDARGS returns the key with an undef value, which
    satisfies the attribute check, which means the default sub is never
    run and the default value never set.
    
    This commit fixes the BUILDARGS logic to first check if the value
    is defined in the config before setting it into the attribute.

diff --git a/lib/App/wsgetmail/MDA.pm b/lib/App/wsgetmail/MDA.pm
index 908e333..ba7d0a7 100644
--- a/lib/App/wsgetmail/MDA.pm
+++ b/lib/App/wsgetmail/MDA.pm
@@ -158,7 +158,14 @@ has debug => (
 my @config_fields = qw( command command_args command_timeout debug );
 around BUILDARGS => sub {
     my ( $orig, $class, $config ) = @_;
-    my $attributes = { map { $_ => $config->{$_} } @config_fields };
+
+    my $attributes = {
+        map {
+            defined $config->{$_} && $_ => $config->{$_}
+        }
+        @config_fields
+    };
+
     return $class->$orig($attributes);
 };
 
@@ -187,6 +194,7 @@ sub _run_command {
         warn "no action to delivery message, command option is empty or null" if ($self->debug);
         return 1;
     }
+
     my $ok = run ([ $self->command, _split_command_args($self->command_args, 1)], $fh, \$output, \$error, timeout( $self->command_timeout + 5 ) );
     unless ($ok) {
         warn sprintf('failed to run command "%s %s" for file %s : %s',
diff --git a/lib/App/wsgetmail/MS365.pm b/lib/App/wsgetmail/MS365.pm
index 4015827..49ca0d1 100644
--- a/lib/App/wsgetmail/MS365.pm
+++ b/lib/App/wsgetmail/MS365.pm
@@ -229,7 +229,13 @@ my @config_fields = qw(client_id tenant_id username user_password global_access
 around BUILDARGS => sub {
   my ( $orig, $class, $config ) = @_;
 
-  my $attributes = { map { $_ => $config->{$_} } @config_fields };
+    my $attributes = {
+        map {
+            defined $config->{$_} && $_ => $config->{$_}
+        }
+        @config_fields
+    };
+
   return $class->$orig($attributes);
 };
 

commit f75cfa64156d4433e566ed6bffe7d69e79dae50c
Author: Blaine Motsinger <blaine at bestpractical.com>
Date:   Wed Apr 20 14:08:19 2022 -0500

    Add vim and config to gitignore and manifest skip

diff --git a/.gitignore b/.gitignore
index 91d3464..7299e00 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,3 +16,6 @@ pod2htm*.tmp
 pm_to_blib
 App-wsgetmail-*
 App-wsgetmail-*.tar.gz
+*.swp
+*.swo
+wsgetmail.json
diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP
index 504fc9d..db2cf05 100644
--- a/MANIFEST.SKIP
+++ b/MANIFEST.SKIP
@@ -4,3 +4,6 @@ Makefile$
 MYMETA.*
 blib/*
 pm_to_blib
+*.swp
+*.swo
+wsgetmail.json

commit b993f53248c4cbf3ef694e62b1042f90629951df
Author: Blaine Motsinger <blaine at bestpractical.com>
Date:   Wed Apr 20 13:44:29 2022 -0500

    Add documention for command_timeout config value

diff --git a/README.md b/README.md
index ceb6d8f..c7ef00d 100644
--- a/README.md
+++ b/README.md
@@ -19,6 +19,7 @@ where `wsgetmail.json` looks like:
     "folder": "Inbox",
     "command": "/opt/rt5/bin/rt-mailgate",
     "command_args": "--url=http://rt.example.com/ --queue=General --action=comment",
+    "command_timeout": 30,
     "action_on_fetched": "mark_as_read"
     }
 
@@ -215,6 +216,11 @@ configuration file.
     with a backslash, and denote a single string argument with single or
     double quotes.
 
+- command\_timeout
+
+    Set this to the number of seconds the `command` has to return before
+    timeout is reached.  The default value is 30.
+
 - action\_on\_fetched
 
     Set this to a literal string `"mark_as_read"` or `"delete"`.
diff --git a/bin/wsgetmail b/bin/wsgetmail
index 6e9a2a0..2218417 100755
--- a/bin/wsgetmail
+++ b/bin/wsgetmail
@@ -120,6 +120,7 @@ where C<wsgetmail.json> looks like:
     "folder": "Inbox",
     "command": "/opt/rt5/bin/rt-mailgate",
     "command_args": "--url=http://rt.example.com/ --queue=General --action=comment",
+    "command_timeout": 30,
     "action_on_fetched": "mark_as_read"
     }
 
diff --git a/lib/App/wsgetmail.pm b/lib/App/wsgetmail.pm
index fab5bdc..fb27160 100644
--- a/lib/App/wsgetmail.pm
+++ b/lib/App/wsgetmail.pm
@@ -75,6 +75,7 @@ where C<wsgetmail.json> looks like:
     "folder": "Inbox",
     "command": "/opt/rt5/bin/rt-mailgate",
     "command_args": "--url=http://rt.example.com/ --queue=General --action=comment",
+    "command_timeout": 30,
     "action_on_fetched": "mark_as_read"
     }
 
@@ -424,6 +425,11 @@ These arguments follow shell quoting rules: you can escape characters
 with a backslash, and denote a single string argument with single or
 double quotes.
 
+=item command_timeout
+
+Set this to the number of seconds the C<command> has to return before
+timeout is reached.  The default value is 30.
+
 =item action_on_fetched
 
 Set this to a literal string C<"mark_as_read"> or C<"delete">.

-----------------------------------------------------------------------


hooks/post-receive
-- 
app-wsgetmail


More information about the Bps-public-commit mailing list