userId = $UserId; $this->appName = $AppName; $this->appManager = $appManager; $this->eventDispatcher = $eventDispatcher; $this->initialState = $initialState; $this->userSession = $userSession; $this->config = $config; } /** * @NoAdminRequired * * @NoCSRFRequired */ public function main() { $user = $this->userSession->getUser(); if (null === $user) { return null; } // Scripts Util::addScript($this->appName, 'memories-main'); $this->eventDispatcher->dispatchTyped(new LoadSidebar()); // Configuration $uid = $user->getUID(); $this->initialState->provideInitialState('timelinePath', $this->config->getUserValue( $uid, Application::APPNAME, 'timelinePath', 'EMPTY' )); $this->initialState->provideInitialState('foldersPath', $this->config->getUserValue( $uid, Application::APPNAME, 'foldersPath', '/' )); $this->initialState->provideInitialState('showHidden', $this->config->getUserValue( $uid, Application::APPNAME, 'showHidden', false )); // Apps enabled $this->initialState->provideInitialState('systemtags', true === $this->appManager->isEnabledForUser('systemtags')); $this->initialState->provideInitialState('maps', true === $this->appManager->isEnabledForUser('maps')); $this->initialState->provideInitialState('recognize', \OCA\Memories\Util::recognizeIsEnabled($this->appManager)); $this->initialState->provideInitialState('facerecognitionInstalled', \OCA\Memories\Util::facerecognitionIsInstalled($this->appManager)); $this->initialState->provideInitialState('facerecognitionEnabled', \OCA\Memories\Util::facerecognitionIsEnabled($this->config, $uid)); $this->initialState->provideInitialState('albums', \OCA\Memories\Util::albumsIsEnabled($this->appManager)); // Common state self::provideCommonInitialState($this->initialState); $response = new TemplateResponse($this->appName, 'main'); $response->setContentSecurityPolicy(self::getCSP()); return $response; } /** Get the common content security policy */ public static function getCSP() { $policy = new ContentSecurityPolicy(); $policy->addAllowedWorkerSrcDomain("'self'"); $policy->addAllowedScriptDomain("'self'"); // Video player $policy->addAllowedWorkerSrcDomain('blob:'); $policy->addAllowedScriptDomain('blob:'); $policy->addAllowedMediaDomain('blob:'); // Image editor $policy->addAllowedConnectDomain('data:'); // Allow nominatim for metadata $policy->addAllowedConnectDomain('nominatim.openstreetmap.org'); $policy->addAllowedFrameDomain('www.openstreetmap.org'); return $policy; } /** Provide initial state for all pages */ public static function provideCommonInitialState(IInitialState &$initialState) { $appManager = \OC::$server->get(\OCP\App\IAppManager::class); $config = \OC::$server->get(\OCP\IConfig::class); // App version $initialState->provideInitialState('version', $appManager->getAppInfo('memories')['version']); // Video configuration $initialState->provideInitialState('notranscode', $config->getSystemValue('memories.no_transcode', 'UNSET')); } /** * @NoAdminRequired * * @NoCSRFRequired */ public function folder() { return $this->main(); } /** * @NoAdminRequired * * @NoCSRFRequired */ public function favorites() { return $this->main(); } /** * @NoAdminRequired * * @NoCSRFRequired */ public function albums() { return $this->main(); } /** * @NoAdminRequired * * @NoCSRFRequired */ public function videos() { return $this->main(); } /** * @NoAdminRequired * * @NoCSRFRequired */ public function archive() { return $this->main(); } /** * @NoAdminRequired * * @NoCSRFRequired */ public function thisday() { return $this->main(); } /** * @NoAdminRequired * * @NoCSRFRequired */ public function recognize() { return $this->main(); } /** * @NoAdminRequired * * @NoCSRFRequired */ public function facerecognition() { return $this->main(); } /** * @NoAdminRequired * * @NoCSRFRequired */ public function tags() { return $this->main(); } }