@@ -266,31 +266,46 @@ export class StreamService {
266266
267267 private async getShareVisibleResources (
268268 share : Share ,
269- reqResources ? : PrivateSearchResourceDto [ ] ,
269+ reqResources : PrivateSearchResourceDto [ ] ,
270270 ) : Promise < PrivateSearchResourceDto [ ] > {
271- const resources : PrivateSearchResourceDto [ ] = [ ] ;
272- for ( const reqResource of reqResources || [ ] ) {
273- const resource = await this . sharedResourcesService . getAndValidateResource (
271+ if ( reqResources . length === 0 ) {
272+ const resources =
273+ await this . sharedResourcesService . getAllSharedResources ( share ) ;
274+ return resources . map ( ( r ) => {
275+ return {
276+ id : r . id ,
277+ name : r . name || '' ,
278+ type : r . resourceType === ResourceType . FOLDER ? 'folder' : 'resource' ,
279+ } as PrivateSearchResourceDto ;
280+ } ) ;
281+ }
282+
283+ const visibleResources : PrivateSearchResourceDto [ ] = [ ...reqResources ] ;
284+ for ( const reqResource of reqResources ) {
285+ // Check if the resource is in the share
286+ await this . sharedResourcesService . getAndValidateResource (
274287 share ,
275288 reqResource . id ,
276289 ) ;
277- const childIds : string [ ] = [ ] ;
278290 if ( reqResource . type === 'folder' ) {
279291 const subResources = await this . resourcesService . getSubResources (
280292 share . namespaceId ,
281293 reqResource . id ,
282294 ) ;
283- childIds . push ( ...subResources . map ( ( r ) => r . id ) ) ;
295+ reqResource . child_ids = subResources . map ( ( r ) => r . id ) ;
296+ visibleResources . push (
297+ ...subResources . map ( ( r ) => {
298+ return {
299+ id : r . id ,
300+ name : r . name || '' ,
301+ type :
302+ r . resourceType === ResourceType . FOLDER ? 'folder' : 'resource' ,
303+ } as PrivateSearchResourceDto ;
304+ } ) ,
305+ ) ;
284306 }
285- resources . push ( {
286- id : resource . id ,
287- name : resource . name ,
288- type :
289- resource . resourceType === ResourceType . FOLDER ? 'folder' : 'resource' ,
290- child_ids : childIds ,
291- } ) ;
292307 }
293- return resources ;
308+ return visibleResources ;
294309 }
295310
296311 private async createAgentStream (
@@ -397,12 +412,10 @@ export class StreamService {
397412 try {
398413 for ( const tool of requestDto . tools || [ ] ) {
399414 if ( tool . name == 'private_search' ) {
400- const visibleResources = await this . getShareVisibleResources (
415+ tool . visible_resources = await this . getShareVisibleResources (
401416 share ,
402- tool . resources ,
417+ tool . resources || [ ] ,
403418 ) ;
404- tool . visible_resources = visibleResources ;
405- tool . resources = visibleResources ;
406419 }
407420 }
408421 return this . createAgentStream (
0 commit comments