]> source.dussan.org Git - nextcloud-server.git/commitdiff
Hide .mov for live photos
authorLouis Chemineau <louis@chmn.me>
Wed, 8 Nov 2023 13:52:50 +0000 (14:52 +0100)
committerLouis Chemineau <louis@chmn.me>
Thu, 9 Nov 2023 21:39:52 +0000 (22:39 +0100)
Signed-off-by: Louis Chemineau <louis@chmn.me>
apps/dav/lib/Connector/Sabre/FilesPlugin.php
apps/files/src/init.ts
apps/files/src/services/LivePhotos.ts [new file with mode: 0644]
apps/files/src/views/FilesList.vue
dist/settings-vue-settings-personal-security.js.LICENSE.txt [deleted file]

index cd188872019cc61bad28f67a3f0afe803f17e71a..c52805c95488db0af802c97fda251dbad7562250 100644 (file)
@@ -87,6 +87,7 @@ class FilesPlugin extends ServerPlugin {
        public const SUBFOLDER_COUNT_PROPERTYNAME = '{http://nextcloud.org/ns}contained-folder-count';
        public const SUBFILE_COUNT_PROPERTYNAME = '{http://nextcloud.org/ns}contained-file-count';
        public const FILE_METADATA_PREFIX = '{http://nextcloud.org/ns}metadata-';
+       public const HIDDEN_PROPERTYNAME = '{http://nextcloud.org/ns}hidden';
 
        /** Reference to main server object */
        private ?Server $server = null;
@@ -386,6 +387,12 @@ class FilesPlugin extends ServerPlugin {
                                $propFind->handle(self::FILE_METADATA_PREFIX . $metadataKey, $metadataValue);
                        }
 
+                       $propFind->handle(self::HIDDEN_PROPERTYNAME, function () use ($node) {
+                               $filesMetadataManager = \OCP\Server::get(IFilesMetadataManager::class);
+                               $metadata = $filesMetadataManager->getMetadata((int)$node->getFileId(), true);
+                               return $metadata->hasKey('files-live-photo') && $node->getFileInfo()->getMimetype() === 'video/quicktime' ? 'true' : 'false';
+                       });
+
                        /**
                         * Return file/folder name as displayname. The primary reason to
                         * implement it this way is to avoid costly fallback to
index 430b17ae7ae0a377ade07c853a002f62fff90eb4..aa855ed69b2fe5ac83cd09ddd6eeda225596168c 100644 (file)
@@ -20,7 +20,7 @@
  *
  */
 import MenuIcon from '@mdi/svg/svg/sun-compass.svg?raw'
-import { FileAction, addNewFileMenuEntry, registerFileAction } from '@nextcloud/files'
+import { FileAction, addNewFileMenuEntry, registerDavProperty, registerFileAction } from '@nextcloud/files'
 
 import { action as deleteAction } from './actions/deleteAction'
 import { action as downloadAction } from './actions/downloadAction'
@@ -41,6 +41,8 @@ import registerPreviewServiceWorker from './services/ServiceWorker.js'
 
 import './init-templates'
 
+import { initLivePhotos } from './services/LivePhotos'
+
 // Register file actions
 registerFileAction(deleteAction)
 registerFileAction(downloadAction)
@@ -63,3 +65,7 @@ registerRecentView()
 
 // Register preview service worker
 registerPreviewServiceWorker()
+
+registerDavProperty('nc:hidden', { nc: 'http://nextcloud.org/ns' })
+
+initLivePhotos()
diff --git a/apps/files/src/services/LivePhotos.ts b/apps/files/src/services/LivePhotos.ts
new file mode 100644 (file)
index 0000000..df6c9de
--- /dev/null
@@ -0,0 +1,33 @@
+/**
+ * @copyright Copyright (c) 2023 Louis Chmn <louis@chmn.me>
+ *
+ * @author Louis Chmn <louis@chmn.me>
+ *
+ * @license AGPL-3.0-or-later
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+import { Node, registerDavProperty } from '@nextcloud/files'
+
+export function initLivePhotos(): void {
+       registerDavProperty('nc:metadata-files-live-photo', { nc: 'http://nextcloud.org/ns' })
+}
+
+/**
+ * @param {Node} node - The node
+ */
+export function isLivePhoto(node: Node): boolean {
+       return node.attributes['metadata-files-live-photo'] !== null
+}
index 89ce6aeb7b03dc747083a70976acfe6f662d5df2..3bc4f27c2a24ebe362c82130af720a482915b618 100644 (file)
@@ -256,7 +256,10 @@ export default Vue.extend({
                },
 
                dirContents(): Node[] {
-                       return (this.currentFolder?._children || []).map(this.getNode).filter(file => file)
+                       return (this.currentFolder?._children || [])
+                               .map(this.getNode)
+                               .filter(file => file)
+                               .filter(file => file?.attributes?.hidden !== true)
                },
 
                /**
diff --git a/dist/settings-vue-settings-personal-security.js.LICENSE.txt b/dist/settings-vue-settings-personal-security.js.LICENSE.txt
deleted file mode 100644 (file)
index 40f5cb7..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*!
- * vue-qrcode v1.0.2
- * https://fengyuanchen.github.io/vue-qrcode
- *
- * Copyright 2018-present Chen Fengyuan
- * Released under the MIT license
- *
- * Date: 2020-01-18T06:04:33.222Z
- */
-
-/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */