#68 - create comment create working (notification to adapt)

This commit is contained in:
isUnknown 2024-12-18 16:26:55 +01:00
parent 3d4ddc12fc
commit cf83edc1e6
11 changed files with 106 additions and 158 deletions

View file

@ -16,27 +16,26 @@ use adrienpayet\notifications\Notification;
*/
return function ($project, $notificationData) {
$recipients = $project->managers()->without($this);
$recipients = $project->managers()->without($this);
if ($recipients->isEmpty()) return;
if ($recipients->isEmpty()) return;
$notificationData['isRead'] = false;
$newNotification = new Notification($notificationData);
foreach ($recipients as $otherUser) {
try {
$notifications = $otherUser->notifications()->isNotEmpty()
? Yaml::decode($otherUser->notifications()->value())
: [];
$newNotification = new Notification($notificationData);
$notifications[] = $newNotification->toArray();
foreach ($recipients as $otherUser) {
try {
$notifications = $otherUser->notifications()->isNotEmpty()
? Yaml::decode($otherUser->notifications()->value())
: [];
$notifications[] = $newNotification->toArray();
$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);
}
}
$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);
}
}
};