Skip to content
Open
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
2 changes: 2 additions & 0 deletions lib/Service/PermissionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function setAccessToken(string $token) {
/**
* Get current user permissions for a board by id
*
* @throws DoesNotExistException
* @return array<Acl::PERMISSION_*, bool>
*/
public function getPermissions(int $boardId, ?string $userId = null, bool $allowDeleted = false): array {
Expand Down Expand Up @@ -143,6 +144,7 @@ public function matchPermissions(Board $board) {
* check permissions for replacing dark magic middleware
*
* @throws NoPermissionException
* @throws DoesNotExistException
*/
public function checkPermission(?IPermissionMapper $mapper, $id, int $permission, $userId = null, bool $allowDeletedCard = false, bool $allowDeletedBoard = false): bool {
$boardId = (int)$id;
Expand Down
21 changes: 18 additions & 3 deletions lib/Sharing/DeckShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ private function createShareObject(array $data): IShare {
return $share;
}

/**
* @throws DoesNotExistException
*/
private function applyBoardPermission($share, $permissions, $userId) {
try {
$this->permissionService->checkPermission($this->cardMapper, $share->getSharedWith(), Acl::PERMISSION_EDIT, $userId, true);
Expand Down Expand Up @@ -622,7 +625,11 @@ public function getShareById($id, $recipientId = null) {
$share = $this->createShareObject($data);

if ($recipientId !== null) {
$share = $this->resolveSharesForRecipient([$share], $recipientId)[0];
$resolvedShares = $this->resolveSharesForRecipient([$share], $recipientId);
if ($resolvedShares === []) {
throw new ShareNotFound();
}
$share = $resolvedShares[0];
}

return $share;
Expand Down Expand Up @@ -675,8 +682,16 @@ private function resolveSharesForRecipient(array $shares, string $userId): array
$stmt = $query->executeQuery();

while ($data = $stmt->fetch()) {
$this->applyBoardPermission($shareMap[$data['parent']], (int)$data['permissions'], $userId);
$shareMap[$data['parent']]->setTarget($data['file_target']);
if (!isset($shareMap[$data['parent']])) {
continue;
}

try {
$this->applyBoardPermission($shareMap[$data['parent']], (int)$data['permissions'], $userId);
$shareMap[$data['parent']]->setTarget($data['file_target']);
} catch (DoesNotExistException $e) {
unset($shareMap[$data['parent']]);
}
}

$stmt->closeCursor();
Expand Down
Loading