[Bps-public-commit] app-wsgetmail branch fix-and-document-command_timeout created. 090a301e5c222a4590ee675fed7b637a17a32b5f
BPS Git Server
git at git.bestpractical.com
Thu Apr 21 21:05:17 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 090a301e5c222a4590ee675fed7b637a17a32b5f (commit)
- Log -----------------------------------------------------------------
commit 090a301e5c222a4590ee675fed7b637a17a32b5f
Author: Blaine Motsinger <blaine at bestpractical.com>
Date: Wed Apr 20 18:35:19 2022 -0500
Add comments about BUILDARGS for object attributes
diff --git a/lib/App/wsgetmail/MDA.pm b/lib/App/wsgetmail/MDA.pm
index aa5c142..eb18e47 100644
--- a/lib/App/wsgetmail/MDA.pm
+++ b/lib/App/wsgetmail/MDA.pm
@@ -154,6 +154,9 @@ has debug => (
);
+# this sets the attributes in the object using values from the config.
+# if no value is defined in the config, the attribute's "default" is used
+# instead (if defined).
around BUILDARGS => sub {
my ( $orig, $class, $config ) = @_;
diff --git a/lib/App/wsgetmail/MS365.pm b/lib/App/wsgetmail/MS365.pm
index 48a1e00..f0048c8 100644
--- a/lib/App/wsgetmail/MS365.pm
+++ b/lib/App/wsgetmail/MS365.pm
@@ -225,6 +225,9 @@ has _next_fetch_url => (
);
+# this sets the attributes in the object using values from the config.
+# if no value is defined in the config, the attribute's "default" is used
+# instead (if defined).
around BUILDARGS => sub {
my ( $orig, $class, $config ) = @_;
commit 1a9421ddc8dc0a07294b8c0620cbc18fbabbc559
Author: Blaine Motsinger <blaine at bestpractical.com>
Date: Wed Apr 20 18:24:02 2022 -0500
Move config_fields array into BUILDARGS sub
The config_files array is only used inside of BUILDARGS.
diff --git a/lib/App/wsgetmail/MDA.pm b/lib/App/wsgetmail/MDA.pm
index af3f6a9..aa5c142 100644
--- a/lib/App/wsgetmail/MDA.pm
+++ b/lib/App/wsgetmail/MDA.pm
@@ -154,8 +154,6 @@ has debug => (
);
-
-my @config_fields = qw( command command_args command_timeout debug );
around BUILDARGS => sub {
my ( $orig, $class, $config ) = @_;
@@ -166,7 +164,7 @@ around BUILDARGS => sub {
grep {
defined $config->{$_}
}
- @config_fields
+ qw(command command_args command_timeout debug)
};
return $class->$orig($attributes);
diff --git a/lib/App/wsgetmail/MS365.pm b/lib/App/wsgetmail/MS365.pm
index 88e24ef..48a1e00 100644
--- a/lib/App/wsgetmail/MS365.pm
+++ b/lib/App/wsgetmail/MS365.pm
@@ -225,7 +225,6 @@ 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 ) = @_;
@@ -236,7 +235,7 @@ around BUILDARGS => sub {
grep {
defined $config->{$_}
}
- @config_fields
+ qw(client_id tenant_id username user_password global_access secret folder post_fetch_action debug)
};
return $class->$orig($attributes);
commit 27ab43dfb7d4f8cc72e0ab874e67f2e8761d554d
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 e2c5aeb..88e24ef 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 {
@@ -239,7 +239,7 @@ around BUILDARGS => sub {
@config_fields
};
- return $class->$orig($attributes);
+ return $class->$orig($attributes);
};
commit b56eff4fe81b8b67bb6e0b8887642b8151c9678f
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..af3f6a9 100644
--- a/lib/App/wsgetmail/MDA.pm
+++ b/lib/App/wsgetmail/MDA.pm
@@ -158,7 +158,17 @@ 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 {
+ $_ => $config->{$_}
+ }
+ grep {
+ defined $config->{$_}
+ }
+ @config_fields
+ };
+
return $class->$orig($attributes);
};
@@ -187,6 +197,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..e2c5aeb 100644
--- a/lib/App/wsgetmail/MS365.pm
+++ b/lib/App/wsgetmail/MS365.pm
@@ -229,7 +229,16 @@ 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 {
+ $_ => $config->{$_}
+ }
+ grep {
+ defined $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