Skip to content
Merged
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
41 changes: 40 additions & 1 deletion lib/Share/RoomShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use OCP\Share\Exceptions\GenericShareException;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager as IShareManager;
use OCP\Share\IPartialShareProvider;
use OCP\Share\IShare;
use OCP\Share\IShareProvider;

Expand All @@ -44,7 +45,7 @@
* Like in group shares, a recipient can move or delete a share without
* modifying the share for the other users in the room.
*/
class RoomShareProvider implements IShareProvider {
class RoomShareProvider implements IShareProvider, IPartialShareProvider {
use TTransactional;
// Special share type for user modified room shares
public const SHARE_TYPE_USERROOM = 11;
Expand Down Expand Up @@ -792,6 +793,33 @@ public function getSharesByPath(Node $path): array {
*/
#[\Override]
public function getSharedWith($userId, $shareType, $node, $limit, $offset): array {
return $this->_getSharedWith($userId, $limit, $offset, $node);
}

#[\Override]
public function getSharedWithByPath(
string $userId,
int $shareType,
string $path,
bool $forChildren,
int $limit,
int $offset,
): iterable {
return $this->_getSharedWith($userId, $limit, $offset, null, $path, $forChildren);
}

/**
* Get received shared for the given user.
* You can optionally provide a node or a path to filter the shares.
*/
private function _getSharedWith(
string $userId,
int $limit,
int $offset,
?Node $node = null,
?string $path = null,
?bool $forChildren = false,
): iterable {
$allRooms = $this->manager->getRoomTokensWithAttachmentsForUser($userId);

if (empty($allRooms)) {
Expand Down Expand Up @@ -824,6 +852,17 @@ public function getSharedWith($userId, $shareType, $node, $limit, $offset): arra
$qb->andWhere($qb->expr()->eq('s.file_source', $qb->createNamedParameter($node->getId())));
}

if ($path !== null) {
$qb->leftJoin('s', 'share', 'sc', $qb->expr()->eq('s.parent', 'sc.id'))
->andWhere($qb->expr()->eq('sc.share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERROOM)));

if ($forChildren) {
$qb->andWhere($qb->expr()->like('s.file_target', $qb->createNamedParameter($this->dbConnection->escapeLikeParameter($path) . '_%')));
} else {
$qb->andWhere($qb->expr()->eq('s.file_target', $qb->createNamedParameter($path)));
}
}

$qb->andWhere($qb->expr()->eq('s.share_type', $qb->createNamedParameter(IShare::TYPE_ROOM)))
->andWhere($qb->expr()->in('s.share_with', $qb->createNamedParameter(
$rooms,
Expand Down
Loading