Skip to content
Open
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 @@
*/
#[\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 {

Check failure on line 807 in lib/Share/RoomShareProvider.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InvalidReturnType

lib/Share/RoomShareProvider.php:807:5: InvalidReturnType: The declared return type 'iterable<mixed, OCP\Share\IShare>' for OCA\Talk\Share\RoomShareProvider::getSharedWithByPath is incorrect, got 'array<array-key, mixed>' (see https://psalm.dev/011)
return $this->_getSharedWith($userId, $limit, $offset, null, $path, $forChildren);

Check failure on line 808 in lib/Share/RoomShareProvider.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InvalidReturnStatement

lib/Share/RoomShareProvider.php:808:10: InvalidReturnStatement: The inferred type 'array<array-key, mixed>' does not match the declared return type 'iterable<mixed, OCP\Share\IShare>' for OCA\Talk\Share\RoomShareProvider::getSharedWithByPath (see https://psalm.dev/128)
}

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

if (empty($allRooms)) {
Expand Down Expand Up @@ -824,6 +852,17 @@
$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