mark as unread if comment is in notifications working
This commit is contained in:
parent
b99f7c81dd
commit
65a2bbaa8d
4 changed files with 36 additions and 3 deletions
|
|
@ -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);
|
||||
}
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue