/** * @NoAdminRequired * @NoCSRFRequired * * @return JSONResponse */ public function get() { // When there are no apps registered that use the notifications // We stop polling for them. if (!$this->manager->hasNotifiers()) { $response = new Response(); $response->setStatus(Http::STATUS_NO_CONTENT); return $response; } $filter = $this->manager->createNotification(); $filter->setUser($this->user); $language = $this->config->getUserValue($this->user, 'core', 'lang', null); $notifications = $this->handler->get($filter); $data = []; $notificationIds = []; foreach ($notifications as $notificationId => $notification) { try { $notification = $this->manager->prepare($notification, $language); } catch (\InvalidArgumentException $e) { // The app was disabled, skip the notification continue; } $notificationIds[] = $notificationId; $data[] = $this->notificationToArray($notificationId, $notification); } $response = new JSONResponse($data); $response->setETag($this->generateEtag($notificationIds)); return $response; }