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..42f399c5fb693 100644 --- a/lib/public/Sharing/ShareUser.php +++ b/lib/public/Sharing/ShareUser.php @@ -46,15 +46,20 @@ public function isCurrentUser(ShareAccessContext $accessContext): bool { * @since 35.0.0 */ public function format(IUserManager $userManager): array { - $ownerUser = $userManager->get($this->userId); - if ($ownerUser === null) { - throw new RuntimeException('The userId does not exist: ' . $this->userId); + if ($this->instance !== null) { + // TODO: Support federation + throw new RuntimeException('Currently only local users are supported.'); + } + + $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),