From 11876436367fe69b0d3ef636172c90d2e62582cf Mon Sep 17 00:00:00 2001 From: Julius Knorr Date: Tue, 30 Dec 2025 10:35:52 +0100 Subject: [PATCH 1/2] chore: Expose IUser object of internal DTO Signed-off-by: Julius Knorr --- lib/Db/User.php | 11 ++++++++--- lib/Service/PermissionService.php | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/Db/User.php b/lib/Db/User.php index 7c50aa9b1..3902b177e 100644 --- a/lib/Db/User.php +++ b/lib/Db/User.php @@ -7,6 +7,7 @@ namespace OCA\Deck\Db; +use OCP\IUser; use OCP\IUserManager; class User extends RelationalObject { @@ -18,7 +19,7 @@ public function __construct($uid, IUserManager $userManager) { }); } - public function getObjectSerialization() { + public function getObjectSerialization(): array { return [ 'uid' => $this->getObject()->getUID(), 'displayname' => $this->getDisplayName(), @@ -26,11 +27,15 @@ public function getObjectSerialization() { ]; } - public function getUID() { + public function getUID(): string { return $this->getPrimaryKey(); } - public function getDisplayName() { + public function getDisplayName(): ?string { return $this->userManager->getDisplayName($this->getPrimaryKey()); } + + public function getUserObject(): IUser { + return $this->getObject(); + } } diff --git a/lib/Service/PermissionService.php b/lib/Service/PermissionService.php index 0f8831daa..fc0fb1e9a 100644 --- a/lib/Service/PermissionService.php +++ b/lib/Service/PermissionService.php @@ -207,7 +207,7 @@ public function userCan(array $acls, $permission, $userId = null) { * Required to allow assigning them to cards * * @param $boardId - * @return array + * @return User[] */ public function findUsers($boardId, $refresh = false) { // cache users of a board so we don't query them for every cards From 54c280cb3933858492a20200117fcc3f09de4f72 Mon Sep 17 00:00:00 2001 From: Julius Knorr Date: Tue, 30 Dec 2025 10:37:34 +0100 Subject: [PATCH 2/2] chore: Implement getUsersForShare on share provider Signed-off-by: Julius Knorr --- lib/Sharing/DeckShareProvider.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/Sharing/DeckShareProvider.php b/lib/Sharing/DeckShareProvider.php index ca0dbc5e7..e9504234b 100644 --- a/lib/Sharing/DeckShareProvider.php +++ b/lib/Sharing/DeckShareProvider.php @@ -33,6 +33,7 @@ use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; use OCP\Share\IShare; +use OCP\Share\IShareProviderGetUsers; /** Taken from the talk shareapicontroller helper */ interface IShareProviderBackend { @@ -42,7 +43,7 @@ public function formatShare(IShare $share): array; public function canAccessShare(IShare $share, string $user): bool; } -class DeckShareProvider implements \OCP\Share\IShareProvider { +class DeckShareProvider implements \OCP\Share\IShareProvider, IShareProviderGetUsers { public const DECK_FOLDER = '/Deck'; public const DECK_FOLDER_PLACEHOLDER = '/{DECK_PLACEHOLDER}'; @@ -1067,4 +1068,20 @@ public function getOrphanedAttachmentShares(): array { return $shares; } + + public function getUsersForShare(IShare $share): iterable { + if ($share->getShareType() === IShare::TYPE_DECK) { + $cardId = (int)$share->getSharedWith(); + $boardId = $this->cardMapper->findBoardId($cardId); + if ($boardId === null) { + return []; + } + + foreach ($this->permissionService->findUsers($boardId) as $user) { + yield $user->getUserObject(); + } + } + + return []; + } }