mirror of
git://f0xx.org/ac/ac-ms-issues
synced 2026-07-29 02:17:57 +03:00
26 lines
760 B
PHP
26 lines
760 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
require_once __DIR__ . '/../../src/bootstrap.php';
|
|
|
|
if (!Auth::user()) {
|
|
json_out(['ok' => false, 'error' => 'unauthorized'], 401);
|
|
}
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
json_out(['ok' => false, 'error' => 'POST required'], 405);
|
|
}
|
|
|
|
$raw = file_get_contents('php://input');
|
|
$data = is_string($raw) && $raw !== '' ? json_decode($raw, true) : $_POST;
|
|
$id = (int) ($data['id'] ?? 0);
|
|
if ($id <= 0) {
|
|
json_out(['ok' => false, 'error' => 'invalid id'], 400);
|
|
}
|
|
|
|
try {
|
|
ReportRepository::markViewed($id, (int) Auth::user()['id']);
|
|
json_out(['ok' => true, 'id' => $id]);
|
|
} catch (Throwable $e) {
|
|
error_log('report_viewed: ' . $e->getMessage());
|
|
json_out(['ok' => false, 'error' => 'failed'], 500);
|
|
}
|