From 227458b960d6ab5db401a3e877636d9f29c62ab7 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Mon, 20 Jul 2026 13:09:06 +0200 Subject: [PATCH 1/2] feat(Sharing): Hard fail on federated shares for now Signed-off-by: provokateurin --- lib/public/Sharing/Recipient/ShareRecipient.php | 5 +++++ lib/public/Sharing/ShareUser.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/public/Sharing/Recipient/ShareRecipient.php b/lib/public/Sharing/Recipient/ShareRecipient.php index 3181700f2afd9..c76bf8bee5209 100644 --- a/lib/public/Sharing/Recipient/ShareRecipient.php +++ b/lib/public/Sharing/Recipient/ShareRecipient.php @@ -52,6 +52,11 @@ public function format(ISharingRegistry $registry, IFactory $l10nFactory, IURLGe throw new RuntimeException('The recipient type is not registered: ' . $this->class); } + if ($this->instance !== null) { + // TODO: Support federation + throw new RuntimeException('Currently only local recipients are supported.'); + } + $displayName = $recipientType->getRecipientDisplayName($this->value) ?? $this->value; if (!$isUnique) { $displayName .= ' (' . $recipientType->getDisplayName($l10nFactory) . ': ' . $this->value . ')'; diff --git a/lib/public/Sharing/ShareUser.php b/lib/public/Sharing/ShareUser.php index d7fdd0b3a398d..a1e4a64455f90 100644 --- a/lib/public/Sharing/ShareUser.php +++ b/lib/public/Sharing/ShareUser.php @@ -46,6 +46,11 @@ public function isCurrentUser(ShareAccessContext $accessContext): bool { * @since 35.0.0 */ public function format(IUserManager $userManager): array { + if ($this->instance !== null) { + // TODO: Support federation + throw new RuntimeException('Currently only local users are supported.'); + } + $ownerUser = $userManager->get($this->userId); if ($ownerUser === null) { throw new RuntimeException('The userId does not exist: ' . $this->userId); From ee1b85443d10b8a7d97106789a98614c0d013384 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Mon, 20 Jul 2026 13:16:38 +0200 Subject: [PATCH 2/2] perf(ShareUser): Only fetch display name instead of user object Signed-off-by: provokateurin --- lib/public/Sharing/ShareUser.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/public/Sharing/ShareUser.php b/lib/public/Sharing/ShareUser.php index a1e4a64455f90..42f399c5fb693 100644 --- a/lib/public/Sharing/ShareUser.php +++ b/lib/public/Sharing/ShareUser.php @@ -51,15 +51,15 @@ public function format(IUserManager $userManager): array { throw new RuntimeException('Currently only local users are supported.'); } - $ownerUser = $userManager->get($this->userId); - if ($ownerUser === null) { - throw new RuntimeException('The userId does not exist: ' . $this->userId); + $displayName = $userManager->getDisplayName($this->userId); + if ($displayName === null) { + throw new RuntimeException('No display name for user ' . $this->userId); } return [ 'user_id' => $this->userId, 'instance' => $this->instance, - 'display_name' => $ownerUser->getDisplayName(), + 'display_name' => $displayName, 'icon' => (new ShareIconURL( $userManager->getAvatarUrlLight($this->userId, 64), $userManager->getAvatarUrlDark($this->userId, 64),