From 264e0b72ba2a6d2ee642e552de7754d0b15bee10 Mon Sep 17 00:00:00 2001 From: Maxime Renou Date: Wed, 1 Oct 2025 10:46:20 +0200 Subject: [PATCH] add link action --- src/Entity/Action.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Entity/Action.php b/src/Entity/Action.php index 3a13710..f40b404 100644 --- a/src/Entity/Action.php +++ b/src/Entity/Action.php @@ -49,6 +49,23 @@ abstract class Action extends Entity ]; } + public function link($url, $expires = 5) + { + $key = 'pilot_action_' . Str::random(10); + $token = Str::random(40); + + cache()->add($key, $token, now()->addMinutes($expires)); + + $url = $url . (str_contains($url, '?') ? '&' : '?') . "pilot_token=$key|$token"; + + return [ + 'json' => [ + 'type' => 'link', + 'url' => $url, + ], + ]; + } + public function error($message) { return [