diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php index 4fed12e6569df..c2fe4dcb1a0fe 100644 --- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php @@ -81,6 +81,7 @@ class FilesPlugin extends ServerPlugin { public const MOUNT_TYPE_PROPERTYNAME = '{http://nextcloud.org/ns}mount-type'; public const MOUNT_ROOT_PROPERTYNAME = '{http://nextcloud.org/ns}is-mount-root'; public const IS_ENCRYPTED_PROPERTYNAME = '{http://nextcloud.org/ns}is-encrypted'; + public const IS_FEDERATED_PROPERTYNAME = '{http://nextcloud.org/ns}is-federated'; public const METADATA_ETAG_PROPERTYNAME = '{http://nextcloud.org/ns}metadata_etag'; public const UPLOAD_TIME_PROPERTYNAME = '{http://nextcloud.org/ns}upload_time'; public const CREATION_TIME_PROPERTYNAME = '{http://nextcloud.org/ns}creation_time'; @@ -149,6 +150,7 @@ public function initialize(Server $server) { $server->protectedProperties[] = self::HAS_PREVIEW_PROPERTYNAME; $server->protectedProperties[] = self::MOUNT_TYPE_PROPERTYNAME; $server->protectedProperties[] = self::IS_ENCRYPTED_PROPERTYNAME; + $server->protectedProperties[] = self::IS_FEDERATED_PROPERTYNAME; $server->protectedProperties[] = self::SHARE_NOTE; // normally these cannot be changed (RFC4918), but we want them modifiable through PROPPATCH @@ -413,6 +415,11 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node) $propFind->handle(self::DISPLAYNAME_PROPERTYNAME, function () use ($node) { return $node->getName(); }); + + $propFind->handle(self::IS_FEDERATED_PROPERTYNAME, function () use ($node) { + return $node->getFileInfo()->getMountPoint() + instanceof \OCA\Files_Sharing\External\Mount; + }); } if ($node instanceof \OCA\DAV\Connector\Sabre\File) { diff --git a/apps/files/src/init.ts b/apps/files/src/init.ts index c3b4b570e12ca..8816ffe81996d 100644 --- a/apps/files/src/init.ts +++ b/apps/files/src/init.ts @@ -70,5 +70,6 @@ registerPreviewServiceWorker() registerDavProperty('nc:hidden', { nc: 'http://nextcloud.org/ns' }) registerDavProperty('nc:is-mount-root', { nc: 'http://nextcloud.org/ns' }) +registerDavProperty('nc:is-federated', { nc: 'http://nextcloud.org/ns' }) initLivePhotos() diff --git a/apps/files_sharing/src/actions/sharingStatusAction.ts b/apps/files_sharing/src/actions/sharingStatusAction.ts index 4f9648fa27f80..8dd1b40330490 100644 --- a/apps/files_sharing/src/actions/sharingStatusAction.ts +++ b/apps/files_sharing/src/actions/sharingStatusAction.ts @@ -29,25 +29,13 @@ import LinkSvg from '@mdi/svg/svg/link.svg?raw' import CircleSvg from '../../../../core/img/apps/circles.svg?raw' import { action as sidebarAction } from '../../../files/src/actions/sidebarAction' -import { generateUrl } from '@nextcloud/router' import { getCurrentUser } from '@nextcloud/auth' +import { generateAvatarSvg } from '../utils/AccountIcon.ts' import './sharingStatusAction.scss' -const isDarkMode = window?.matchMedia?.('(prefers-color-scheme: dark)')?.matches === true - || document.querySelector('[data-themes*=dark]') !== null - -const generateAvatarSvg = (userId: string, isGuest = false) => { - const url = isDarkMode ? '/avatar/{userId}/32/dark' : '/avatar/{userId}/32' - const avatarUrl = generateUrl(isGuest ? url : url + '?guestFallback=true', { userId }) - return ` - - ` -} - const isExternal = (node: Node) => { - return node.attributes.remote_id !== undefined + return node.attributes?.['is-federated'] ?? false } export const action = new FileAction({ @@ -110,7 +98,8 @@ export const action = new FileAction({ const ownerId = node?.attributes?.['owner-id'] if (ownerId && (ownerId !== getCurrentUser()?.uid || isExternal(node))) { - return generateAvatarSvg(ownerId, isExternal(node)) + const sanitizeId = (id: string) => id.replace(/[^a-zA-Z0-9._%+@-]+/g, '').replace(/\//g, '') + return generateAvatarSvg(sanitizeId(ownerId), isExternal(node)) } return AccountPlusSvg diff --git a/apps/files_sharing/src/utils/AccountIcon.ts b/apps/files_sharing/src/utils/AccountIcon.ts new file mode 100644 index 0000000000000..ccae8d50c8224 --- /dev/null +++ b/apps/files_sharing/src/utils/AccountIcon.ts @@ -0,0 +1,18 @@ +/*! + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +import { generateUrl } from '@nextcloud/router' + +const isDarkMode = window?.matchMedia?.('(prefers-color-scheme: dark)')?.matches === true + || document.querySelector('[data-themes*=dark]') !== null + +export const generateAvatarSvg = (userId: string, isExternalUser = false) => { + console.log('User ID:', userId) + const url = isDarkMode ? '/avatar/{userId}/32/dark' : '/avatar/{userId}/32' + const avatarUrl = generateUrl(isExternalUser ? url + '?guestFallback=true' : url, { userId }) + return ` + + ` +}