mark as unread if comment is in notifications working
This commit is contained in:
parent
b99f7c81dd
commit
65a2bbaa8d
4 changed files with 36 additions and 3 deletions
|
|
@ -6,4 +6,15 @@ Uuid: s0lNtRA0Z7ybTCWG
|
|||
|
||||
----
|
||||
|
||||
Template: document
|
||||
Template: document
|
||||
|
||||
----
|
||||
|
||||
Comments:
|
||||
|
||||
1:
|
||||
m2lyhnf7:
|
||||
text: nouveau com
|
||||
username: Adrien Payet
|
||||
date: 2024-10-23T16:14:54+02:00
|
||||
id: m2lyhnf7
|
||||
|
|
@ -20,15 +20,28 @@ return [
|
|||
'text' => $data->text,
|
||||
'username' => $user->name()->isNotEmpty() ? (string) $user->name() : (string) $user->email(),
|
||||
'date' => (string) $data->date,
|
||||
'id' => $data->id
|
||||
];
|
||||
|
||||
$comments[$data->targetPage][$data->id] = $newComment;
|
||||
|
||||
|
||||
$newFile = $file->update([
|
||||
'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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return getFileData($newFile);
|
||||
}
|
||||
];
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
user: {
|
||||
role: '<?= $kirby->user()->role() ?>',
|
||||
uuid: '<?= $kirby->user()->uuid() ?>',
|
||||
notifications: <?= json_encode(Yaml::decode($kirby->user()->notifications()->value())) ?>
|
||||
<?php if ($kirby->user()->role() == 'client'): ?>
|
||||
client: {
|
||||
name: '<?= $kirby->user()->client()->toPage()->title() ?>',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue