#68 - finish notification class. Content notification on validate brief working

This commit is contained in:
isUnknown 2024-12-18 13:56:21 +01:00
parent 3fb043210e
commit fa36c9ef4a
12 changed files with 246 additions and 24 deletions

View file

@ -7,12 +7,12 @@ return [
$json = file_get_contents('php://input');
$data = json_decode($json);
$brief = page($data->briefUri);
$project = $brief->parent();
$href = $data->dialogUri ? $data->dialogUri : $brief->url();
$page = page($data->briefUri);
$project = $page->parent();
$dialogUri = $data->dialogUri ? $data->dialogUri : null;
try {
$newPage = $brief->update([
$newPage = $page->update([
'isValidated' => 'true'
]);
@ -21,20 +21,13 @@ return [
$notification = [
'location' => [
'href' => (string) $href,
'project' => [
'title' => (string) $project->title(),
'uri' => (string) $project->url()
]
'page' => $page,
'project' => $project,
'dialogUri' => (string) $dialogUri,
],
'date' => $dateTime->format('Y-m-d\TH:i:sP'),
'text' => "Brief (" . $project->title()->value() . ")",
'author' => [
'name' => (string) kirby()->user()->name(),
'email' => (string) kirby()->user()->email(),
'uuid' => (string) kirby()->user()->uuid(),
'role' => (string) kirby()->user()->role(),
],
'author' => kirby()->user(),
'id' => Str::uuid(),
'type' => 'content'
];
@ -46,7 +39,7 @@ return [
];
} catch (\Throwable $th) {
return [
"error" => "Can't validate '" . $brief->title()->value() . "' brief.",
"error" => "Can't validate '" . $page->title()->value() . "' brief.",
'details' => $th->getMessage()
];
}