From 3f7ea970e4c1af13a2091bcd367905449b5ef215 Mon Sep 17 00:00:00 2001 From: Corentin Mors Date: Mon, 12 Oct 2020 21:19:14 +0200 Subject: Implement "your video" tab Signed-off-by: Corentin Mors --- lib/AppInfo/Application.php | 5 ++++- lib/Controller/AlbumsController.php | 3 ++- lib/Controller/PageController.php | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index de3ade2a..760d1149 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -33,7 +33,7 @@ use OCP\AppFramework\Bootstrap\IRegistrationContext; class Application extends App implements IBootstrap { public const APP_ID = 'photos'; - public const MIMES = [ + public const IMAGE_MIMES = [ 'image/png', 'image/jpeg', 'image/heic', @@ -41,6 +41,9 @@ class Application extends App implements IBootstrap { // 'image/x-xbitmap', // too rarely used for photos // 'image/bmp', // too rarely used for photos // 'image/svg+xml', // too rarely used for photos + ]; + + public const VIDEO_MIMES = [ // 'video/mpeg', // too rarely used for photos // 'video/ogg', // too rarely used for photos // 'video/webm', // too rarely used for photos diff --git a/lib/Controller/AlbumsController.php b/lib/Controller/AlbumsController.php index d047474b..662b6680 100644 --- a/lib/Controller/AlbumsController.php +++ b/lib/Controller/AlbumsController.php @@ -127,7 +127,8 @@ class AlbumsController extends Controller { } private function validFile(File $file, bool $shared): bool { - if (in_array($file->getMimeType(), Application::MIMES) && $this->isShared($file) === $shared) { + $allowed_mimes = array_merge(Application::IMAGE_MIMES, Application::VIDEO_MIMES); + if (in_array($file->getMimeType(), $allowed_mimes) && $this->isShared($file) === $shared) { return true; } diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index effb3e07..3cf92ad6 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -75,7 +75,8 @@ class PageController extends Controller { $this->eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar()); $this->eventDispatcher->dispatch(LoadViewer::class, new LoadViewer()); - $this->initialStateService->provideInitialState($this->appName, 'mimes', Application::MIMES); + $this->initialStateService->provideInitialState($this->appName, 'image-mimes', Application::IMAGE_MIMES); + $this->initialStateService->provideInitialState($this->appName, 'video-mimes', Application::VIDEO_MIMES); $this->initialStateService->provideInitialState($this->appName, 'maps', $this->appManager->isEnabledForUser('maps') === true); Util::addScript($this->appName, 'photos-main'); -- cgit v1.2.3