From a249be1d8b81242d711de3e336f35cb4e9507b35 Mon Sep 17 00:00:00 2001
From: Derf Null <derf@finalrewind.org>
Date: Sun, 18 Jun 2023 08:38:55 +0200
Subject: [PATCH] run webhook when updating checkin comment or visibility

---
 lib/Travelynx/Controller/Traveling.pm | 5 ++++-
 templates/webhooks.html.ep            | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm
index 23fb76dd..63bf832b 100755
--- a/lib/Travelynx/Controller/Traveling.pm
+++ b/lib/Travelynx/Controller/Traveling.pm
@@ -1569,6 +1569,7 @@ sub visibility_form {
 					visibility => $self->param('status_level'),
 				);
 				$self->redirect_to('/');
+				$self->run_hook( $uid, 'update' );
 			}
 			elsif ($journey_id) {
 				$self->journeys->update_visibility(
@@ -1651,11 +1652,13 @@ sub comment_form {
 	}
 	else {
 		$self->app->log->debug("set comment");
+		my $uid = $self->current_user->{id};
 		$self->in_transit->update_user_data(
-			uid       => $self->current_user->{id},
+			uid       => $uid,
 			user_data => { comment => $self->param('comment') }
 		);
 		$self->redirect_to('/');
+		$self->run_hook( $uid, 'update' );
 	}
 }
 
diff --git a/templates/webhooks.html.ep b/templates/webhooks.html.ep
index 7d543bb0..0343f547 100644
--- a/templates/webhooks.html.ep
+++ b/templates/webhooks.html.ep
@@ -89,7 +89,7 @@
 			<ul>
 				<li><b>ping</b> (nach jeder gespeicherten Änderung in diesem Formular)</li>
 				<li><b>checkin</b> (in einen Zug eingecheckt – Zielstation ist noch nicht bekannt)</li>
-				<li><b>update</b> (eingecheckt und Ziel gewählt oder geändert)</li>
+				<li><b>update</b> (eingecheckt und Ziel/Kommentar/Sichtbarkeit geändert)</li>
 				<li><b>checkout</b> (aus einem Zug ausgecheckt)</li>
 				<li><b>undo</b> (checkin oder checkout wurde rückgängig gemacht)</li>
 			</ul>
-- 
GitLab