Add cancel snooze

- Add common request validation function
This commit is contained in:
2024-06-23 06:58:47 -04:00
parent d6e8cf66cc
commit 9421bb2035
11 changed files with 96 additions and 83 deletions

View File

@@ -1,14 +1,10 @@
<?php declare(strict_types=1);
use MyPrayerJournal\{Auth, History, Layout, Note, Request, RequestAction, UI};
use MyPrayerJournal\{History, Layout, Note, RequestAction, UI};
require '../../start.php';
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
Auth::requireUser();
$req = Request::byId($_GET['id']);
if (!$req) not_found();
$req = validate_request($_GET['id'], ['GET']);
$answered = $req->isAnswered() ? new DateTimeImmutable($req->history[0]->asOf) : null;
$prayed = sizeof(array_filter($req->history, fn(History $hist) => $hist->action == RequestAction::Prayed));