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:
parent
2791bc4462
commit
86db1f5a0c
1 changed files with 22 additions and 7 deletions
|
|
@ -59,7 +59,7 @@ class NotificationCollector
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collecte uniquement les données minimales des notifications (version allégée pour listing).
|
* 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 Page $project Le projet à scanner
|
||||||
* @param User $user L'utilisateur courant
|
* @param User $user L'utilisateur courant
|
||||||
|
|
@ -72,18 +72,33 @@ class NotificationCollector
|
||||||
foreach ($this->providers as $provider) {
|
foreach ($this->providers as $provider) {
|
||||||
try {
|
try {
|
||||||
$notifications = $provider->collect($project, $user);
|
$notifications = $provider->collect($project, $user);
|
||||||
// Ne garder que les champs essentiels
|
// Garder les champs nécessaires au frontend
|
||||||
foreach ($notifications as $notification) {
|
foreach ($notifications as $notification) {
|
||||||
$all[] = [
|
$light = [
|
||||||
'id' => $notification['id'] ?? null,
|
'id' => $notification['id'] ?? null,
|
||||||
'type' => $notification['type'] ?? null,
|
'type' => $notification['type'] ?? null,
|
||||||
'isRead' => $notification['isRead'] ?? false,
|
'isRead' => $notification['isRead'] ?? false,
|
||||||
'date' => $notification['date'] ?? null,
|
'date' => $notification['date'] ?? null,
|
||||||
// Garder location.project.uri pour le frontend
|
'text' => $notification['text'] ?? null,
|
||||||
'location' => [
|
'author' => $notification['author'] ?? null,
|
||||||
'project' => $notification['location']['project'] ?? []
|
'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) {
|
} catch (\Throwable $e) {
|
||||||
error_log("NotificationCollector: Error in {$provider->getType()}: " . $e->getMessage());
|
error_log("NotificationCollector: Error in {$provider->getType()}: " . $e->getMessage());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue