summaryrefslogtreecommitdiff
path: root/lib/Travelynx.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-05-14 20:05:45 +0200
committerDaniel Friesel <derf@finalrewind.org>2019-05-14 20:05:45 +0200
commitb85db3a10df32cb2648607c83d37160ac3ee8691 (patch)
tree3b20a35c32695270ba5bbbc0c2e1fb041184eb96 /lib/Travelynx.pm
parent5c3a0a562a2169986f3f91034b10a5e177c7dff5 (diff)
Show web-hook test result immediately after saving it1.3.3
Closes #12
Diffstat (limited to 'lib/Travelynx.pm')
-rwxr-xr-xlib/Travelynx.pm18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm
index 3284418..c4a2b53 100755
--- a/lib/Travelynx.pm
+++ b/lib/Travelynx.pm
@@ -1059,12 +1059,15 @@ sub startup {
$self->helper(
'run_hook' => sub {
- my ( $self, $uid, $reason ) = @_;
+ my ( $self, $uid, $reason, $callback ) = @_;
my $hook = $self->get_webhook($uid);
if ( not $hook->{enabled} or not $hook->{url} =~ m{^ https?:// }x )
{
+ if ($callback) {
+ &$callback();
+ }
return;
}
@@ -1080,7 +1083,12 @@ sub startup {
}
my $ua = $self->ua;
- $ua->request_timeout(10);
+ if ($callback) {
+ $ua->request_timeout(4);
+ }
+ else {
+ $ua->request_timeout(10);
+ }
$ua->post_p( $hook->{url} => $header => json => $hook_body )->then(
sub {
@@ -1093,11 +1101,17 @@ sub startup {
$self->mark_hook_status( $uid, $hook->{url}, 1,
$tx->result->body );
}
+ if ($callback) {
+ &$callback();
+ }
}
)->catch(
sub {
my ($err) = @_;
$self->mark_hook_status( $uid, $hook->{url}, 0, $err );
+ if ($callback) {
+ &$callback();
+ }
}
)->wait;
}