Skip to content

Commit

Permalink
fix(Federation): Show some icon for federated users on shares
Browse files Browse the repository at this point in the history
Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
  • Loading branch information
Fenn-CS committed Sep 24, 2024
1 parent 79dd819 commit 23f0324
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions apps/dav/lib/Connector/Sabre/FilesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class FilesPlugin extends ServerPlugin {
public const HAS_PREVIEW_PROPERTYNAME = '{http://nextcloud.org/ns}has-preview';
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_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';
Expand Down Expand Up @@ -118,6 +119,7 @@ public function initialize(Server $server) {
$server->protectedProperties[] = self::DATA_FINGERPRINT_PROPERTYNAME;
$server->protectedProperties[] = self::HAS_PREVIEW_PROPERTYNAME;
$server->protectedProperties[] = self::MOUNT_TYPE_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
Expand Down Expand Up @@ -412,6 +414,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) {
Expand Down
1 change: 1 addition & 0 deletions apps/files/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,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()
2 changes: 1 addition & 1 deletion apps/files_sharing/src/actions/sharingStatusAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { generateAvatarSvg } from '../utils/AccountIcon'
import './sharingStatusAction.scss'

const isExternal = (node: Node) => {
return node.attributes.remote_id !== undefined
return node.attributes?.['is-federated'] ?? false
}

export const action = new FileAction({
Expand Down
4 changes: 2 additions & 2 deletions apps/files_sharing/src/utils/AccountIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ 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, isGuest = false) => {
export const generateAvatarSvg = (userId: string, isExternalUser = false) => {
const url = isDarkMode ? '/avatar/{userId}/32/dark' : '/avatar/{userId}/32'
const avatarUrl = generateUrl(isGuest ? url : url + '?guestFallback=true', { userId })
const avatarUrl = generateUrl(isExternalUser ? url + '?guestFallback=true' : url, { userId })
return `<svg width="32" height="32" viewBox="0 0 32 32"
xmlns="http://www.w3.org/2000/svg" class="sharing-status__avatar">
<image href="${avatarUrl}" height="32" width="32" />
Expand Down

0 comments on commit 23f0324

Please sign in to comment.