1313use OCA \Files \Service \ViewConfig ;
1414use OCP \AppFramework \Controller ;
1515use OCP \AppFramework \Http ;
16+ use OCP \AppFramework \Http \Attribute \NoAdminRequired ;
17+ use OCP \AppFramework \Http \Attribute \NoCSRFRequired ;
1618use OCP \AppFramework \Http \Attribute \OpenAPI ;
19+ use OCP \AppFramework \Http \Attribute \PublicPage ;
20+ use OCP \AppFramework \Http \Attribute \StrictCookiesRequired ;
1721use OCP \AppFramework \Http \ContentSecurityPolicy ;
1822use OCP \AppFramework \Http \DataResponse ;
1923use OCP \AppFramework \Http \FileDisplayResponse ;
@@ -69,10 +73,6 @@ public function __construct(string $appName,
6973 *
7074 * @since API version 1.0
7175 *
72- * @NoAdminRequired
73- * @NoCSRFRequired
74- * @StrictCookieRequired
75- *
7676 * @param int $x Width of the thumbnail
7777 * @param int $y Height of the thumbnail
7878 * @param string $file URL-encoded filename
@@ -82,6 +82,9 @@ public function __construct(string $appName,
8282 * 400: Getting thumbnail is not possible
8383 * 404: File not found
8484 */
85+ #[NoAdminRequired]
86+ #[NoCSRFRequired]
87+ #[StrictCookiesRequired]
8588 public function getThumbnail ($ x , $ y , $ file ) {
8689 if ($ x < 1 || $ y < 1 ) {
8790 return new DataResponse (['message ' => 'Requested size must be numeric and a positive value. ' ], Http::STATUS_BAD_REQUEST );
@@ -113,12 +116,11 @@ public function getThumbnail($x, $y, $file) {
113116 * The passed tags are absolute, which means they will
114117 * replace the actual tag selection.
115118 *
116- * @NoAdminRequired
117- *
118119 * @param string $path path
119120 * @param array|string $tags array of tags
120121 * @return DataResponse
121122 */
123+ #[NoAdminRequired]
122124 public function updateFileTags ($ path , $ tags = null ) {
123125 $ result = [];
124126 // if tags specified or empty array, update tags
@@ -221,10 +223,9 @@ private function getShareTypesForNodes(array $nodes): array {
221223 /**
222224 * Returns a list of recently modified files.
223225 *
224- * @NoAdminRequired
225- *
226226 * @return DataResponse
227227 */
228+ #[NoAdminRequired]
228229 public function getRecentFiles () {
229230 $ nodes = $ this ->userFolder ->getRecent (100 );
230231 $ files = $ this ->formatNodes ($ nodes );
@@ -235,11 +236,10 @@ public function getRecentFiles() {
235236 /**
236237 * Returns the current logged-in user's storage stats.
237238 *
238- * @NoAdminRequired
239- *
240239 * @param ?string $dir the directory to get the storage stats from
241240 * @return JSONResponse
242241 */
242+ #[NoAdminRequired]
243243 public function getStorageStats ($ dir = '/ ' ): JSONResponse {
244244 $ storageInfo = \OC_Helper::getStorageInfo ($ dir ?: '/ ' );
245245 $ response = new JSONResponse (['message ' => 'ok ' , 'data ' => $ storageInfo ]);
@@ -250,13 +250,12 @@ public function getStorageStats($dir = '/'): JSONResponse {
250250 /**
251251 * Set a user view config
252252 *
253- * @NoAdminRequired
254- *
255253 * @param string $view
256254 * @param string $key
257255 * @param string|bool $value
258256 * @return JSONResponse
259257 */
258+ #[NoAdminRequired]
260259 public function setViewConfig (string $ view , string $ key , $ value ): JSONResponse {
261260 try {
262261 $ this ->viewConfig ->setConfig ($ view , $ key , (string )$ value );
@@ -271,23 +270,21 @@ public function setViewConfig(string $view, string $key, $value): JSONResponse {
271270 /**
272271 * Get the user view config
273272 *
274- * @NoAdminRequired
275- *
276273 * @return JSONResponse
277274 */
275+ #[NoAdminRequired]
278276 public function getViewConfigs (): JSONResponse {
279277 return new JSONResponse (['message ' => 'ok ' , 'data ' => $ this ->viewConfig ->getConfigs ()]);
280278 }
281279
282280 /**
283281 * Set a user config
284282 *
285- * @NoAdminRequired
286- *
287283 * @param string $key
288284 * @param string|bool $value
289285 * @return JSONResponse
290286 */
287+ #[NoAdminRequired]
291288 public function setConfig (string $ key , $ value ): JSONResponse {
292289 try {
293290 $ this ->userConfig ->setConfig ($ key , (string )$ value );
@@ -302,23 +299,21 @@ public function setConfig(string $key, $value): JSONResponse {
302299 /**
303300 * Get the user config
304301 *
305- * @NoAdminRequired
306- *
307302 * @return JSONResponse
308303 */
304+ #[NoAdminRequired]
309305 public function getConfigs (): JSONResponse {
310306 return new JSONResponse (['message ' => 'ok ' , 'data ' => $ this ->userConfig ->getConfigs ()]);
311307 }
312308
313309 /**
314310 * Toggle default for showing/hiding hidden files
315311 *
316- * @NoAdminRequired
317- *
318312 * @param bool $value
319313 * @return Response
320314 * @throws \OCP\PreConditionNotMetException
321315 */
316+ #[NoAdminRequired]
322317 public function showHiddenFiles (bool $ value ): Response {
323318 $ this ->config ->setUserValue ($ this ->userSession ->getUser ()->getUID (), 'files ' , 'show_hidden ' , $ value ? '1 ' : '0 ' );
324319 return new Response ();
@@ -327,12 +322,11 @@ public function showHiddenFiles(bool $value): Response {
327322 /**
328323 * Toggle default for cropping preview images
329324 *
330- * @NoAdminRequired
331- *
332325 * @param bool $value
333326 * @return Response
334327 * @throws \OCP\PreConditionNotMetException
335328 */
329+ #[NoAdminRequired]
336330 public function cropImagePreviews (bool $ value ): Response {
337331 $ this ->config ->setUserValue ($ this ->userSession ->getUser ()->getUID (), 'files ' , 'crop_image_previews ' , $ value ? '1 ' : '0 ' );
338332 return new Response ();
@@ -341,32 +335,27 @@ public function cropImagePreviews(bool $value): Response {
341335 /**
342336 * Toggle default for files grid view
343337 *
344- * @NoAdminRequired
345- *
346338 * @param bool $show
347339 * @return Response
348340 * @throws \OCP\PreConditionNotMetException
349341 */
342+ #[NoAdminRequired]
350343 public function showGridView (bool $ show ): Response {
351344 $ this ->config ->setUserValue ($ this ->userSession ->getUser ()->getUID (), 'files ' , 'show_grid ' , $ show ? '1 ' : '0 ' );
352345 return new Response ();
353346 }
354347
355348 /**
356349 * Get default settings for the grid view
357- *
358- * @NoAdminRequired
359350 */
351+ #[NoAdminRequired]
360352 public function getGridView () {
361353 $ status = $ this ->config ->getUserValue ($ this ->userSession ->getUser ()->getUID (), 'files ' , 'show_grid ' , '0 ' ) === '1 ' ;
362354 return new JSONResponse (['gridview ' => $ status ]);
363355 }
364356
365- /**
366- * @NoAdminRequired
367- * @NoCSRFRequired
368- * @PublicPage
369- */
357+ #[PublicPage]
358+ #[NoCSRFRequired]
370359 #[OpenAPI(scope: OpenAPI::SCOPE_IGNORE )]
371360 public function serviceWorker (): StreamResponse {
372361 $ response = new StreamResponse (__DIR__ . '/../../../../dist/preview-service-worker.js ' );
0 commit comments