new content notification working for client brief
This commit is contained in:
parent
8ae00d7657
commit
c1d2c73118
9 changed files with 277 additions and 70 deletions
|
|
@ -33,7 +33,7 @@ return [
|
|||
'y' => $data->position->y
|
||||
],
|
||||
'replies' => [],
|
||||
'text' => $data->text,
|
||||
'text' => $user->name()->isNotEmpty() ? $user->name()->value() . ' : ' . $data->text : $user->email()->value() . ' : ' . $data->text,
|
||||
'author' => $user,
|
||||
'date' => (string) $data->date,
|
||||
'id' => $data->id,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,14 @@ return [
|
|||
$json = file_get_contents('php://input');
|
||||
$data = json_decode($json);
|
||||
|
||||
$page = page($data->pageUri);
|
||||
$parsedUrl = parse_url($data->path);
|
||||
$query = $parsedUrl['query'] ?? null;
|
||||
parse_str($query, $queryParams);
|
||||
$stepSlug = $queryParams['dialog'] ?? null;
|
||||
|
||||
$targetPageUri = $stepSlug ? $parsedUrl['path'] . '/' . $stepSlug : $parsedUrl['path'];
|
||||
|
||||
$page = page($targetPageUri);
|
||||
$file = $page->file($data->fileName);
|
||||
$user = kirby()->user($data->userUuid);
|
||||
|
||||
|
|
@ -17,6 +24,7 @@ return [
|
|||
$comments = $file->comments()->isEmpty() == true ? [] : Yaml::decode($file->comments()->value());
|
||||
|
||||
$data = [
|
||||
'href' => $data->path,
|
||||
'page' => $page,
|
||||
'parentId' => $data->parentId,
|
||||
'file' => $file,
|
||||
|
|
|
|||
|
|
@ -13,25 +13,27 @@
|
|||
* @throws Exception If an error occurs while updating a user's notifications.
|
||||
*/
|
||||
|
||||
return function ($project, $notificationData) {
|
||||
return function ($project, $notificationData) {
|
||||
$recipients = $project->managers()->without($this);
|
||||
|
||||
if (!$recipients) return;
|
||||
|
||||
$notificationData['isRead'];
|
||||
foreach ($recipients as $otherUser) {
|
||||
try {
|
||||
$notifications = $otherUser->notifications()->isNotEmpty()
|
||||
? Yaml::decode($otherUser->notifications()->value())
|
||||
: [];
|
||||
|
||||
$notifications[] = $notificationData;
|
||||
|
||||
$otherUser->update([
|
||||
'notifications' => $notifications
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
throw new Exception("Error updating notifications: " . $th->getMessage() . ' line ' . $th->getLine(), 1);
|
||||
}
|
||||
if ($recipients->isEmpty()) return;
|
||||
|
||||
$notificationData['isRead'] = false;
|
||||
|
||||
foreach ($recipients as $otherUser) {
|
||||
try {
|
||||
$notifications = $otherUser->notifications()->isNotEmpty()
|
||||
? Yaml::decode($otherUser->notifications()->value())
|
||||
: [];
|
||||
|
||||
$notifications[] = $notificationData;
|
||||
|
||||
$otherUser->update([
|
||||
'notifications' => $notifications
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
error_log("Notification error for user " . $otherUser->email() . ": " . $th->getMessage());
|
||||
throw new Exception("Error updating notifications: " . $th->getMessage() . ' line ' . $th->getLine(), 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue