mark as unread if comment is in notifications working

This commit is contained in:
isUnknown 2024-10-23 16:19:33 +02:00
parent b99f7c81dd
commit 65a2bbaa8d
4 changed files with 36 additions and 3 deletions

View file

@ -20,15 +20,28 @@ return [
'text' => $data->text,
'username' => $user->name()->isNotEmpty() ? (string) $user->name() : (string) $user->email(),
'date' => (string) $data->date,
'id' => $data->id
];
$comments[$data->targetPage][$data->id] = $newComment;
$newFile = $file->update([
'comments' => $comments
]);
foreach (kirby()->users()->without($user) as $otherUser) {
try {
$notifications = $otherUser->notifications()->isNotEmpty() ? $otherUser->notifications()->toArray() : ["comments" => []];
$notifications['comments'][$data->id] = $newComment;
$otherUser->update([
"notifications" => $notifications
]);
} catch (\Throwable $th) {
throw new Exception($th->getMessage(), 1);
}
}
return getFileData($newFile);
}
];