From 269b8536f42ee7b872f112c31490f2a44e345f23 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 10 May 2019 19:03:18 +0200 Subject: [PATCH] Add webhook to account page --- lib/Travelynx.pm | 2 +- lib/Travelynx/Controller/Account.pm | 5 ++++- templates/account.html.ep | 31 ++++++++++++++++++++++++++--- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 3840518..001a762 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -1045,7 +1045,7 @@ sub startup { $self->pg->db->update( 'webhooks', { - errored => !$success, + errored => $success ? 0 : 1, latest_run => DateTime->now( time_zone => 'Europe/Berlin' ), output => $text, }, diff --git a/lib/Travelynx/Controller/Account.pm b/lib/Travelynx/Controller/Account.pm index c02fb1a..e272eb1 100644 --- a/lib/Travelynx/Controller/Account.pm +++ b/lib/Travelynx/Controller/Account.pm @@ -222,6 +222,8 @@ sub privacy { $public_level &= ~0x02; } $self->set_privacy( $user->{id}, $public_level ); + + $self->flash( success => 'privacy' ); $self->redirect_to('account'); } else { @@ -244,8 +246,9 @@ sub webhook { token => $hook->{token}, enabled => $hook->{enabled} ); + $self->flash( success => 'webhook' ); + $self->redirect_to('account'); $self->run_hook( $self->current_user->{id}, 'ping' ); - $hook = $self->get_webhook; } else { $self->param( url => $hook->{url} ); diff --git a/templates/account.html.ep b/templates/account.html.ep index 7baacbe..05e0447 100644 --- a/templates/account.html.ep +++ b/templates/account.html.ep @@ -8,10 +8,16 @@
% if ($success eq 'mail') { - Mail-Adresse erfolgreich geändert + Mail-Adresse geändert % } % elsif ($success eq 'password') { - Passwort erfolgreich geändert + Passwort geändert + % } + % elsif ($success eq 'privacy') { + Einstellungen zu öffentliche Account-Daten geändert + % } + % elsif ($success eq 'webhook') { + Web Hook aktualisiert % }
@@ -21,6 +27,7 @@

Account

% my $acc = current_user(); +% my $hook = get_webhook();
@@ -41,13 +48,31 @@ + + + +
edit % if ($acc->{is_public} == 0) { - Keine + Keine % } % if ($acc->{is_public} & 0x02) { Aktueller Status % }
Web Hook + edit + % if ($hook->{enabled} == 0) { + Nicht eingerichtet + % } + % elsif ($hook->{latest_run}->epoch == 0) { + Aktiv, noch nicht ausgeführt + % } + % elsif ($hook->{errored}) { + Aktiv, fehlerhaft error + % } + % else { + Aktiv + % } +
Registriert am <%= $acc->{registered_at}->strftime('%d.%m.%Y %H:%M') %>