Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/Db/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace OCA\Deck\Db;

use OCP\IUser;
use OCP\IUserManager;

class User extends RelationalObject {
Expand All @@ -18,19 +19,23 @@ public function __construct($uid, IUserManager $userManager) {
});
}

public function getObjectSerialization() {
public function getObjectSerialization(): array {
return [
'uid' => $this->getObject()->getUID(),
'displayname' => $this->getDisplayName(),
'type' => Acl::PERMISSION_TYPE_USER
];
}

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();
}
}
2 changes: 1 addition & 1 deletion lib/Service/PermissionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 18 additions & 1 deletion lib/Sharing/DeckShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}';

Expand Down Expand Up @@ -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 [];
}
}
Loading