Skip to content

Commit

Permalink
fix(sharing): Get shared collective by token
Browse files Browse the repository at this point in the history
Fixes opening shares if there's more than one for a collective.

Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Dec 18, 2023
1 parent c39542d commit 56fcc6e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/Controller/PublicCollectiveController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ public function get(int $pageId = 0): DataResponse {
}
$collective = $this->service->getCollectiveWithShare($share->getCollectiveId(),
$share->getPageId(),
$share->getOwner());
$share->getOwner(),
$share->getToken());
// Explicitly set member level
$collective->setLevel(Member::LEVEL_MEMBER);
return [
Expand Down
11 changes: 6 additions & 5 deletions lib/Service/CollectiveService.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,19 @@ private function initPageVersionsBackend(): void {
}

/**
* @param int $id
* @param int $pageId
* @param string $userId
* @param int $id
* @param int $pageId
* @param string $userId
* @param string|null $shareToken
*
* @return CollectiveInfo
* @throws MissingDependencyException
* @throws NotFoundException
* @throws NotPermittedException
*/
public function getCollectiveWithShare(int $id, int $pageId, string $userId): CollectiveInfo {
public function getCollectiveWithShare(int $id, int $pageId, string $userId, ?string $shareToken = null): CollectiveInfo {
$collectiveInfo = $this->getCollectiveInfo($id, $userId);
if (null !== $share = $this->shareService->findShare($userId, $id, $pageId)) {
if ($shareToken && null !== $share = $this->shareService->findShareByToken($shareToken)) {
$collectiveInfo->setShareToken($share->getToken());
$collectiveInfo->setIsPageShare($share->getPageId() !== 0);
$collectiveInfo->setShareEditable($share->getEditable());
Expand Down

0 comments on commit 56fcc6e

Please sign in to comment.