Skip to content

Commit

Permalink
Merge pull request #1036 from nextcloud/limit-to-memberships
Browse files Browse the repository at this point in the history
+limitToFederatedUserMemberships
  • Loading branch information
ArtificialOwl authored May 5, 2022
2 parents 35589f4 + 7a97622 commit 7bfeb67
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
30 changes: 30 additions & 0 deletions lib/Db/CoreQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,36 @@ public function limitToDirectMembership(string $alias, Member $member): void {
}


/**
* @param string $alias
* @param string $aliasCircle
* @param FederatedUser $federatedUser
*
* @throws RequestBuilderException
*/
public function limitToFederatedUserMemberships(
string $alias,
string $aliasCircle,
FederatedUser $federatedUser
): void {
$aliasMembership = $this->generateAlias($alias, self::MEMBERSHIPS);

$this->leftJoin(
$aliasCircle,
'circles_membership',
$aliasMembership,
$this->expr()->eq($aliasCircle . '.unique_id', $aliasMembership . '.circle_id')
);

$this->andWhere(
$this->expr()->eq(
$aliasMembership . '.single_id',
$this->createNamedParameter($federatedUser->getSingleId())
)
);
}


/**
* @param string $aliasMember
* @param Member $member
Expand Down
16 changes: 3 additions & 13 deletions lib/Db/ShareWrapperRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,20 +292,10 @@ public function getSharedWith(
)
);

$getData = true;
if ($getData) {
$qb->leftJoinCircle(CoreQueryBuilder::SHARE, null, 'share_with');
}
$qb->leftJoinCircle(CoreQueryBuilder::SHARE, null, 'share_with');

$qb->leftJoin(
'sh_cc',
'circles_membership',
'sh_ms',
$qb->expr()->eq('sh_cc.unique_id', 'sh_ms.circle_id')
);
$qb->andWhere(
$qb->expr()->eq('sh_ms.single_id', $qb->createNamedParameter($federatedUser->getSingleId()))
);
$aliasCircle = $qb->generateAlias(CoreQueryBuilder::SHARE, CoreQueryBuilder::CIRCLE);
$qb->limitToFederatedUserMemberships(CoreQueryBuilder::SHARE, $aliasCircle, $federatedUser);

$qb->leftJoinFileCache(CoreQueryBuilder::SHARE);
$qb->limitNull('parent', false);
Expand Down

0 comments on commit 7bfeb67

Please sign in to comment.