, admin: list}}, array{}>|DataResponse, array{}> * * 200: Changes returned * 204: No changes */ #[NoAdminRequired] #[ApiRoute(verb: 'GET', url: '/whatsnew', root: '/core')] public function get():DataResponse { $user = $this->userSession->getUser(); if ($user === null) { throw new \RuntimeException('Acting user cannot be resolved'); } $lastRead = $this->config->getUserValue($user->getUID(), 'core', 'whatsNewLastRead', 0); $currentVersion = $this->whatsNewService->normalizeVersion($this->config->getSystemValue('version')); if (version_compare($lastRead, $currentVersion, '>=')) { return new DataResponse([], Http::STATUS_NO_CONTENT); } try { $iterator = $this->langFactory->getLanguageIterator(); $whatsNew = $this->whatsNewService->getChangesForVersion($currentVersion); $resultData = [ 'changelogURL' => $whatsNew['changelogURL'], 'product' => $this->defaults->getProductName(), 'version' => $currentVersion, ]; do { $lang = $iterator->current(); if (isset($whatsNew['whatsNew'][$lang])) { $resultData['whatsNew'] = $whatsNew['whatsNew'][$lang]; break; } $iterator->next(); } while ($lang !== 'en' && $iterator->valid()); return new DataResponse($resultData); } catch (DoesNotExistException $e) { return new DataResponse([], Http::STATUS_NO_CONTENT); } } /** * Dismiss the changes * * @param string $version Version to dismiss the changes for * * @return DataResponse, array{}> * @throws \OCP\PreConditionNotMetException * @throws DoesNotExistException * * 200: Changes dismissed */ #[NoAdminRequired] #[ApiRoute(verb: 'POST', url: '/whatsnew', root: '/core')] public function dismiss(string $version):DataResponse { $user = $this->userSession->getUser(); if ($user === null) { throw new \RuntimeException('Acting user cannot be resolved'); } $version = $this->whatsNewService->normalizeVersion($version); // checks whether it's a valid version, throws an Exception otherwise $this->whatsNewService->getChangesForVersion($version); $this->config->setUserValue($user->getUID(), 'core', 'whatsNewLastRead', $version); return new DataResponse(); } }