Skip to content

Commit

Permalink
Merge pull request #5595 from nextcloud/backport/4485/stable25
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusknorr authored Feb 14, 2024
2 parents 5801565 + aeb6917 commit 3ff9248
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/Service/PermissionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,23 @@ public function getPermissions($boardId, ?string $userId = null) {
$userId = $this->userId;
}

if ($cached = $this->permissionCache->get($boardId)) {
$cacheKey = $boardId . '-' . $userId;
if ($cached = $this->permissionCache->get($cacheKey)) {
return $cached;
}


$board = $this->getBoard($boardId);
$owner = $this->userIsBoardOwner($boardId, $userId);
$acls = $board->getDeletedAt() === 0 ? $this->aclMapper->findAll($boardId) : [];
$permissions = [
Acl::PERMISSION_READ => $owner || $this->userCan($acls, Acl::PERMISSION_READ),
Acl::PERMISSION_EDIT => $owner || $this->userCan($acls, Acl::PERMISSION_EDIT),
Acl::PERMISSION_MANAGE => $owner || $this->userCan($acls, Acl::PERMISSION_MANAGE),
Acl::PERMISSION_SHARE => ($owner || $this->userCan($acls, Acl::PERMISSION_SHARE))
&& (!$this->shareManager->sharingDisabledForUser($this->userId))
Acl::PERMISSION_READ => $owner || $this->userCan($acls, Acl::PERMISSION_READ, $userId),
Acl::PERMISSION_EDIT => $owner || $this->userCan($acls, Acl::PERMISSION_EDIT, $userId),
Acl::PERMISSION_MANAGE => $owner || $this->userCan($acls, Acl::PERMISSION_MANAGE, $userId),
Acl::PERMISSION_SHARE => ($owner || $this->userCan($acls, Acl::PERMISSION_SHARE, $userId))
&& (!$this->shareManager->sharingDisabledForUser($userId))
];
$this->permissionCache->set((string)$boardId, $permissions);
$this->permissionCache->set($cacheKey, $permissions);
return $permissions;
}

Expand Down

0 comments on commit 3ff9248

Please sign in to comment.