()
| 53 | } |
| 54 | |
| 55 | #[NoAdminRequired] |
| 56 | public function get(): DataResponse |
| 57 | { |
| 58 | $user = $this->userSession->getUser(); |
| 59 | if ($user === null) { |
| 60 | throw new \RuntimeException("Acting user cannot be resolved"); |
| 61 | } |
| 62 | $lastRead = $this->config->getUserValue($user->getUID(), $this->appName, 'whatsNewLastRead', 0); |
| 63 | $currentVersion = $this->whatsNewService->normalizeVersion($this->config->getAppValue($this->appName, 'installed_version')); |
| 64 | |
| 65 | if (version_compare($lastRead, $currentVersion, '>=')) { |
| 66 | return new DataResponse([], Http::STATUS_NO_CONTENT); |
| 67 | } |
| 68 | |
| 69 | try { |
| 70 | $iterator = $this->langFactory->getLanguageIterator(); |
| 71 | $whatsNew = $this->whatsNewService->getChangesForVersion($currentVersion); |
| 72 | |
| 73 | $resultData = [ |
| 74 | 'changelogURL' => $whatsNew['changelogURL'], |
| 75 | 'product' => 'Analytics', |
| 76 | 'version' => $currentVersion, |
| 77 | ]; |
| 78 | do { |
| 79 | $lang = $iterator->current(); |
| 80 | if (isset($whatsNew['whatsNew'][$lang])) { |
| 81 | $resultData['whatsNew'] = $whatsNew['whatsNew'][$lang]; |
| 82 | break; |
| 83 | } |
| 84 | $iterator->next(); |
| 85 | } while ($lang !== 'en' && $iterator->valid()); |
| 86 | return new DataResponse($resultData); |
| 87 | } catch (DoesNotExistException $e) { |
| 88 | return new DataResponse([], Http::STATUS_NO_CONTENT); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * |
no test coverage detected