@@ -719,7 +719,7 @@ public function getSharesByIds(array $ids, ?string $recipientId = null): array {
719719 * @param bool $allRoomShares indicates that the passed in shares are all room shares for the user
720720 * @return list<IShare>
721721 */
722- private function resolveSharesForRecipient (array $ shareMap , string $ userId , ?string $ path = null , bool $ forChildren = false ): array {
722+ private function resolveSharesForRecipient (array $ shareMap , string $ userId , ?string $ path = null , bool $ forChildren = false , bool $ allRoomShares = false ): array {
723723 $ qb = $ this ->dbConnection ->getQueryBuilder ();
724724
725725 $ query = $ qb ->select ('parent ' , 'permissions ' , 'file_target ' )
@@ -732,15 +732,17 @@ private function resolveSharesForRecipient(array $shareMap, string $userId, ?str
732732 $ qb ->expr ()->eq ('item_type ' , $ qb ->createNamedParameter ('folder ' ))
733733 ));
734734
735- if ($ path !== null ) {
736- $ path = str_replace ('/ ' . $ userId . '/files ' , '' , $ path );
737- $ path = rtrim ($ path , '/ ' );
735+ if ($ path !== null || $ allRoomShares ) {
736+ if ($ path !== null ) {
737+ $ path = str_replace ('/ ' . $ userId . '/files ' , '' , $ path );
738+ $ path = rtrim ($ path , '/ ' );
738739
739- if ($ forChildren ) {
740- $ qb ->andWhere ($ qb ->expr ()->like ('file_target ' , $ qb ->createNamedParameter ($ this ->dbConnection ->escapeLikeParameter ($ path ) . '/_% ' )));
741- } else {
742- $ nonChildPath = $ path === '' ? '/ ' : $ path ;
743- $ qb ->andWhere ($ qb ->expr ()->eq ('file_target ' , $ qb ->createNamedParameter ($ nonChildPath )));
740+ if ($ forChildren ) {
741+ $ qb ->andWhere ($ qb ->expr ()->like ('file_target ' , $ qb ->createNamedParameter ($ this ->dbConnection ->escapeLikeParameter ($ path ) . '/_% ' )));
742+ } else {
743+ $ nonChildPath = $ path === '' ? '/ ' : $ path ;
744+ $ qb ->andWhere ($ qb ->expr ()->eq ('file_target ' , $ qb ->createNamedParameter ($ nonChildPath )));
745+ }
744746 }
745747
746748 $ stmt = $ query ->executeQuery ();
@@ -938,7 +940,7 @@ private function _getSharedWith(
938940 $ cursor ->closeCursor ();
939941 }
940942
941- $ shares = $ this ->resolveSharesForRecipient ($ shares , $ userId , $ path , $ forChildren );
943+ $ shares = $ this ->resolveSharesForRecipient ($ shares , $ userId , $ path , $ forChildren, true );
942944
943945 return $ shares ;
944946 }
0 commit comments