Refonte du système de notifications : passage aux notifications dérivées
Remplace le système de notifications stockées par un système de providers qui dérivent les notifications des données existantes (commentaires, réponses, demandes de projet, demandes de rendez-vous, validations de brief). - Ajout du NotificationCollector et de l'interface NotificationProvider - Création de 5 providers : Comment, Reply, ProjectRequest, AppointmentRequest, Content - Métadonnées de notifications stockées directement sur les entités source - Nouvelles routes mark-as-read et mark-all-read - Mise à jour du frontend pour le nouveau système - Route de migration pour les données existantes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c68b51f639
commit
a7d315942a
26 changed files with 1406 additions and 137 deletions
|
|
@ -7,37 +7,26 @@ return [
|
|||
$json = file_get_contents('php://input');
|
||||
$data = json_decode($json);
|
||||
|
||||
$user = kirby()->user();
|
||||
$user = kirby()->user();
|
||||
$project = page($data->projectUri);
|
||||
|
||||
$date = new DateTime();
|
||||
$formattedDate = $date->format(DateTime::ISO8601);
|
||||
|
||||
try {
|
||||
$newProject = $project->update([
|
||||
$project->update([
|
||||
"hasOptimizationRequest" => "true",
|
||||
"optimizationRequestDetails" => esc("De la part de " . kirby()->user()->name() . " (" . kirby()->user()->email() . ") : \n\n" . "Objet : " . $data->subject . "\n" . $data->details)
|
||||
"optimizationRequestDetails" => esc("De la part de " . $user->name() . " (" . $user->email() . ") : \n\n" . "Objet : " . $data->subject . "\n" . $data->details),
|
||||
// Métadonnées pour le système de notifications dérivées
|
||||
"optimizationAuthor" => (string) $user->uuid(),
|
||||
"optimizationAuthorName" => (string) $user->name(),
|
||||
"optimizationAuthorEmail" => (string) $user->email(),
|
||||
"optimizationDate" => $formattedDate,
|
||||
"optimizationReadby" => [],
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
return [
|
||||
"status" => "error",
|
||||
"message" => "Can't update project " . $project->title()->value() . ". " . $th->getMessage() . " in " . $th->getFile() . " line " . $th->getLine()
|
||||
];
|
||||
}
|
||||
|
||||
try {
|
||||
$date = new DateTime();
|
||||
$formattedDate = $date->format(DateTime::ISO8601);
|
||||
|
||||
$notificationData = [
|
||||
"location" => [
|
||||
"page" => $newProject
|
||||
],
|
||||
"date" => (string) $formattedDate,
|
||||
"text" => nl2br("Objet : " . $data->subject . "\n" . esc($data->details)),
|
||||
"author" => $user,
|
||||
"id" => Str::uuid(),
|
||||
"type" => "appointment-request",
|
||||
];
|
||||
|
||||
$newProject->createNotification($notificationData);
|
||||
// Note: Les notifications sont maintenant dérivées.
|
||||
// Plus besoin d'appeler createNotification().
|
||||
|
||||
return [
|
||||
"status" => "success",
|
||||
|
|
@ -45,7 +34,7 @@ return [
|
|||
} catch (\Throwable $th) {
|
||||
return [
|
||||
"status" => "error",
|
||||
"message" => "Can't create notification. " . $th->getMessage() . " in " . $th->getFile() . " line " . $th->getLine()
|
||||
"message" => "Can't update project " . $project->title()->value() . ". " . $th->getMessage() . " in " . $th->getFile() . " line " . $th->getLine()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue