Fix collectLight() : inclure author, text, location pour l'affichage

Problème : collectLight() ne retournait que id/type/isRead/date, causant
notification.author undefined dans le frontend.

Solution : Inclure tous les champs nécessaires à l'affichage (author, text,
location) mais toujours alléger en excluant les gros détails inutiles.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
isUnknown 2026-01-15 11:55:17 +01:00
parent 2791bc4462
commit 86db1f5a0c

View file

@ -59,7 +59,7 @@ class NotificationCollector
/**
* Collecte uniquement les données minimales des notifications (version allégée pour listing).
* Retourne seulement id, type, isRead, date pour économiser la mémoire.
* Retourne les champs nécessaires à l'affichage mais sans les détails lourds.
*
* @param Page $project Le projet à scanner
* @param User $user L'utilisateur courant
@ -72,18 +72,33 @@ class NotificationCollector
foreach ($this->providers as $provider) {
try {
$notifications = $provider->collect($project, $user);
// Ne garder que les champs essentiels
// Garder les champs nécessaires au frontend
foreach ($notifications as $notification) {
$all[] = [
$light = [
'id' => $notification['id'] ?? null,
'type' => $notification['type'] ?? null,
'isRead' => $notification['isRead'] ?? false,
'date' => $notification['date'] ?? null,
// Garder location.project.uri pour le frontend
'location' => [
'project' => $notification['location']['project'] ?? []
]
'text' => $notification['text'] ?? null,
'author' => $notification['author'] ?? null,
'location' => $notification['location'] ?? []
];
// Garder les champs optionnels s'ils existent
if (isset($notification['dialogUri'])) {
$light['dialogUri'] = $notification['dialogUri'];
}
if (isset($notification['_briefUri'])) {
$light['_briefUri'] = $notification['_briefUri'];
}
if (isset($notification['_file'])) {
$light['_file'] = $notification['_file'];
}
if (isset($notification['_projectUri'])) {
$light['_projectUri'] = $notification['_projectUri'];
}
$all[] = $light;
}
} catch (\Throwable $e) {
error_log("NotificationCollector: Error in {$provider->getType()}: " . $e->getMessage());