designtopack/public/site/plugins/notifications/routes/read.php

24 lines
641 B
PHP
Raw Normal View History

2024-12-16 18:14:14 +01:00
<?php
return [
'pattern' => '(:all)read-notification.json',
'method' => 'POST',
'action' => function () {
$json = file_get_contents('php://input');
$data = json_decode($json);
2025-01-10 17:40:45 +01:00
try {
$project = page("projects")->findPageOrDraft($data->projectId);
2025-01-10 17:40:45 +01:00
$project->readNotification($data->notificationId);
return json_encode([
"status" => "success"
]);
} catch (\Throwable $th) {
return json_encode([
"status" => "error",
"message" => $th->getMessage() . ' line ' . $th->getLine() . " in file " . $th->getFile()
]);
}
2024-12-16 18:14:14 +01:00
}
];