File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010use OCA \ContextChat \Service \MetadataService ;
1111use OCA \ContextChat \Service \ProviderConfigService ;
1212use OCP \AppFramework \Controller ;
13+ use OCP \AppFramework \Http ;
1314use OCP \AppFramework \Http \Attribute \NoAdminRequired ;
1415use OCP \AppFramework \Http \DataResponse ;
1516use OCP \IRequest ;
@@ -20,6 +21,7 @@ public function __construct(
2021 string $ appName ,
2122 IRequest $ request ,
2223 private MetadataService $ metadataService ,
24+ private ?string $ userId ,
2325 ) {
2426 parent ::__construct ($ appName , $ request );
2527 }
@@ -48,7 +50,13 @@ public function getProviders(): DataResponse {
4850 */
4951 #[NoAdminRequired]
5052 public function getMetadataFor (array $ sources ): DataResponse {
51- $ enrichedSources = $ this ->metadataService ->getEnrichedSources (...$ sources );
53+ if (empty ($ sources )) {
54+ return new DataResponse ([]);
55+ }
56+ if ($ this ->userId === null ) {
57+ return new DataResponse (['error ' => 'User must be logged in to get metadata for sources ' ], Http::STATUS_UNAUTHORIZED );
58+ }
59+ $ enrichedSources = $ this ->metadataService ->getEnrichedSources ($ this ->userId , ...$ sources );
5260 return new DataResponse ($ enrichedSources );
5361 }
5462}
You can’t perform that action at this time.
0 commit comments