notifications working

This commit is contained in:
isUnknown 2024-11-22 07:53:43 +01:00
parent 699c0bfa1d
commit 8ae00d7657
8 changed files with 28 additions and 202 deletions

View file

@ -53,7 +53,9 @@ return [
try {
$user->sendNotification($page->parent(), $newComment->toArray());
} catch (\Throwable $th) {
return $th->getMessage() . " in " . $th->getFile() . " line " . $th->getLine();
echo json_encode([
"error" => $th->getMessage() . " in " . $th->getFile() . " line " . $th->getLine(),
]);
}
exit;

View file

@ -39,7 +39,7 @@ return [
echo json_encode(getFileData($newFile));
kirby()->user()->deleteNotification($project->managers()->toUsers(), $data->id);
kirby()->user()->deleteNotification($project, $data->id);
exit;
}

View file

@ -1,5 +1,9 @@
<?php
load([
'ProjectPage' => 'models/ProjectPage.php',
], __DIR__);
Kirby::plugin('adrienpayet/pdc-notifications', [
'routes' => [
require(__DIR__ . '/routes/readAll.php'),

View file

@ -1,7 +1,7 @@
<?php
return function($projectManagers, $notificationId) {
foreach ($projectManagers as $projectManager) {
return function($project, $notificationId) {
foreach ($project->managers() as $projectManager) {
try {
$notifications = $projectManager->notifications()->isNotEmpty()
? Yaml::decode($projectManager->notifications()->value())

View file

@ -1,7 +1,6 @@
<?php
return function($notificationId) {
return function($notificationId) {
try {
$notifications = $this->notifications()->isNotEmpty()
? Yaml::decode($this->notifications()->value())

View file

@ -14,22 +14,7 @@
*/
return function ($project, $notificationData) {
$recipients = kirby()->users()->filter(function($user) use ($project) {
if ($user === $this || $user->projects()->isEmpty()) {
return false;
}
throw new Exception(json_encode($user->name()), 1);
$projects = $user->projects();
if ($projects && ($user->role() == 'admin' || $projects->has($project))) {
return false;
}
return false;
});
// $recipients = page($projectUri)->managers()->toUsers()->not($this);
$recipients = $project->managers()->without($this);
if (!$recipients) return;