merge and add opened comment view

This commit is contained in:
isUnknown 2024-10-29 16:13:07 +01:00
parent c3860d4a38
commit 4e4216f8d3
6 changed files with 164 additions and 134 deletions

View file

@ -0,0 +1,26 @@
<?php
return function ($group, $data) {
foreach (kirby()->users()->not($this) as $otherUser) {
try {
$notifications = $otherUser->notifications()->isNotEmpty()
? Yaml::decode($otherUser->notifications()->value())
: [];
if (!isset($notifications[$group])) {
$notifications[$group] = [];
}
$data['isRead'] = false;
$notifications[$group][$data['id']] = $data;
$otherUser->update([
'notifications' => $notifications
]);
} catch (\Throwable $th) {
throw new Exception("Error updating notifications: " . $th->getMessage() . ' line ' . $th->getLine(), 1);
}
}
};