|
31 | 31 | use OCP\Share\Exceptions\GenericShareException; |
32 | 32 | use OCP\Share\Exceptions\ShareNotFound; |
33 | 33 | use OCP\Share\IManager as IShareManager; |
| 34 | +use OCP\Share\IPartialShareProvider; |
34 | 35 | use OCP\Share\IShare; |
35 | 36 | use OCP\Share\IShareProvider; |
36 | 37 |
|
|
44 | 45 | * Like in group shares, a recipient can move or delete a share without |
45 | 46 | * modifying the share for the other users in the room. |
46 | 47 | */ |
47 | | -class RoomShareProvider implements IShareProvider { |
| 48 | +class RoomShareProvider implements IShareProvider, IPartialShareProvider { |
48 | 49 | use TTransactional; |
49 | 50 | // Special share type for user modified room shares |
50 | 51 | public const SHARE_TYPE_USERROOM = 11; |
@@ -792,6 +793,33 @@ public function getSharesByPath(Node $path): array { |
792 | 793 | */ |
793 | 794 | #[\Override] |
794 | 795 | public function getSharedWith($userId, $shareType, $node, $limit, $offset): array { |
| 796 | + return $this->_getSharedWith($userId, $limit, $offset, $node); |
| 797 | + } |
| 798 | + |
| 799 | + #[\Override] |
| 800 | + public function getSharedWithByPath( |
| 801 | + string $userId, |
| 802 | + int $shareType, |
| 803 | + string $path, |
| 804 | + bool $forChildren, |
| 805 | + int $limit, |
| 806 | + int $offset, |
| 807 | + ): iterable { |
| 808 | + return $this->_getSharedWith($userId, $limit, $offset, null, $path, $forChildren); |
| 809 | + } |
| 810 | + |
| 811 | + /** |
| 812 | + * Get received shared for the given user. |
| 813 | + * You can optionally provide a node or a path to filter the shares. |
| 814 | + */ |
| 815 | + private function _getSharedWith( |
| 816 | + string $userId, |
| 817 | + int $limit, |
| 818 | + int $offset, |
| 819 | + ?Node $node = null, |
| 820 | + ?string $path = null, |
| 821 | + ?bool $forChildren = false, |
| 822 | + ): iterable { |
795 | 823 | $allRooms = $this->manager->getRoomTokensWithAttachmentsForUser($userId); |
796 | 824 |
|
797 | 825 | if (empty($allRooms)) { |
@@ -824,6 +852,17 @@ public function getSharedWith($userId, $shareType, $node, $limit, $offset): arra |
824 | 852 | $qb->andWhere($qb->expr()->eq('s.file_source', $qb->createNamedParameter($node->getId()))); |
825 | 853 | } |
826 | 854 |
|
| 855 | + if ($path !== null) { |
| 856 | + $qb->leftJoin('s', 'share', 'sc', $qb->expr()->eq('s.parent', 'sc.id')) |
| 857 | + ->andWhere($qb->expr()->eq('sc.share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERROOM))); |
| 858 | + |
| 859 | + if ($forChildren) { |
| 860 | + $qb->andWhere($qb->expr()->like('s.file_target', $qb->createNamedParameter($this->dbConnection->escapeLikeParameter($path) . '_%'))); |
| 861 | + } else { |
| 862 | + $qb->andWhere($qb->expr()->eq('s.file_target', $qb->createNamedParameter($path))); |
| 863 | + } |
| 864 | + } |
| 865 | + |
827 | 866 | $qb->andWhere($qb->expr()->eq('s.share_type', $qb->createNamedParameter(IShare::TYPE_ROOM))) |
828 | 867 | ->andWhere($qb->expr()->in('s.share_with', $qb->createNamedParameter( |
829 | 868 | $rooms, |
|
0 commit comments