feat: action links, telegram webhook and channels API

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BCrwHHnGCB5XH968Nxokqw
This commit is contained in:
nikita.hohlov
2026-09-04 07:52:12 -03:00
parent 6138ac7bb0
commit 90d17ec378
8 changed files with 450 additions and 10 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Http\Controllers;
use App\Delivery\EventActions;
use App\Models\Delivery;
use App\Models\Event;
use Illuminate\Http\JsonResponse;
/** Кнопки из каналов: подписанные ссылки по action_token доставки. Без SSO и CSRF. */
class ActionController extends Controller
{
public function __construct(private readonly EventActions $actions) {}
public function ack(string $token): JsonResponse
{
$event = $this->eventFor($token);
$this->actions->ack($event);
return response()->json(['state' => $event->fresh()->state->value]);
}
public function done(string $token): JsonResponse
{
$event = $this->eventFor($token);
$this->actions->done($event);
return response()->json(['state' => $event->fresh()->state->value]);
}
private function eventFor(string $token): Event
{
$delivery = Delivery::where('action_token', $token)->with('event.user')->first();
abort_if($delivery === null, 404, 'Неизвестный токен');
abort_if($delivery->event->isTerminal(), 410, 'Событие уже закрыто');
return $delivery->event;
}
}