From d6cf4220d2caf50d7a4f6586110f14bc79382dc0 Mon Sep 17 00:00:00 2001 From: nfebe Date: Thu, 19 Mar 2026 18:37:22 +0100 Subject: [PATCH] fix(files): Check read permission before showing PDF edit action The "Edit with Collabora" file action was displayed for files the user lacks permission to access. Added a Permission.READ check in the enabled callback, consistent with how core Nextcloud file actions gate on node permissions. Signed-off-by: nfebe --- src/file-actions.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/file-actions.js b/src/file-actions.js index 76317a3df9..12217c3d4f 100644 --- a/src/file-actions.js +++ b/src/file-actions.js @@ -2,7 +2,8 @@ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ -import { registerFileAction, FileAction } from '@nextcloud/files' + +import { Permission, registerFileAction, FileAction } from '@nextcloud/files' import { getCapabilities } from './services/capabilities.ts' import { translate as t } from '@nextcloud/l10n' @@ -28,7 +29,12 @@ const openPdf = new FileAction({ return false } + if ((files[0].permissions & Permission.READ) === 0) { + return false + } + const isPdf = files[0].mime === 'application/pdf' + // Only enable the file action when files_pdfviewer is enabled const optionalMimetypes = getCapabilities().mimetypesNoDefaultOpen return isPdf && optionalMimetypes.includes('application/pdf')