fix send notification to users and create custom user method

This commit is contained in:
isUnknown 2024-10-28 15:02:28 +01:00
parent 9dcb054973
commit f132049948
3 changed files with 133 additions and 12 deletions

View file

@ -29,18 +29,7 @@ return [
'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);
}
}
$user->sendNotification('comments', $newComment);
return getFileData($newFile);
}