death-notifier/src/main/php/com/fwdekker/deathnotifier/tracking/ListTrackingsAction.php

37 lines
901 B
PHP

<?php
namespace com\fwdekker\deathnotifier\tracking;
use com\fwdekker\deathnotifier\Action;
use com\fwdekker\deathnotifier\ActionException;
use com\fwdekker\deathnotifier\ActionMethod;
class ListTrackingsAction extends Action
{
private readonly TrackingManager $tracking_manager;
public function __construct(TrackingManager $tracking_manager)
{
parent::__construct(
ActionMethod::GET,
"list-trackings",
require_logged_in: true,
require_valid_csrf_token: true,
);
$this->tracking_manager = $tracking_manager;
}
function handle(): mixed
{
$response = $this->tracking_manager->list_trackings($_SESSION["uuid"]);
if (!$response->satisfied)
throw new ActionException($response->payload["message"], $response->payload["target"]);
return $response->payload;
}
}