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
|
|
@ -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