2024-11-17 12:01:20 +01:00
|
|
|
<?php
|
|
|
|
|
|
2024-11-22 07:53:43 +01:00
|
|
|
return function($project, $notificationId) {
|
2025-01-10 15:38:57 +01:00
|
|
|
foreach (kirby()->users() as $user) {
|
2024-11-18 12:00:19 +01:00
|
|
|
try {
|
2025-01-10 15:38:57 +01:00
|
|
|
$notifications = $user->notifications()->isNotEmpty()
|
|
|
|
|
? Yaml::decode($user->notifications()->value())
|
2024-11-18 12:00:19 +01:00
|
|
|
: [];
|
|
|
|
|
|
|
|
|
|
foreach ($notifications as $key => $notification) {
|
|
|
|
|
if ($notification['id'] === $notificationId) {
|
|
|
|
|
unset($notifications[$key]);
|
|
|
|
|
}
|
2024-11-17 12:01:20 +01:00
|
|
|
}
|
2024-11-18 12:00:19 +01:00
|
|
|
|
2025-01-10 15:38:57 +01:00
|
|
|
$user->update([
|
2024-11-18 12:00:19 +01:00
|
|
|
'notifications' => Yaml::encode(array_values($notifications))
|
|
|
|
|
]);
|
|
|
|
|
} catch (\Throwable $th) {
|
|
|
|
|
throw new Exception("Error updating notifications: " . $th->getMessage() . ' line ' . $th->getLine(), 1);
|
2024-11-17 12:01:20 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|