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 );
@@ -109,12 +112,11 @@ public function getThumbnail($x, $y, $file) {
109112 * The passed tags are absolute, which means they will
110113 * replace the actual tag selection.
111114 *
112- * @NoAdminRequired
113- *
114115 * @param string $path path
115116 * @param array|string $tags array of tags
116117 * @return DataResponse
117118 */
119+ #[NoAdminRequired]
118120 public function updateFileTags ($ path , $ tags = null ) {
119121 $ result = [];
120122 // if tags specified or empty array, update tags
@@ -217,10 +219,9 @@ private function getShareTypesForNodes(array $nodes): array {
217219 /**
218220 * Returns a list of recently modified files.
219221 *
220- * @NoAdminRequired
221- *
222222 * @return DataResponse
223223 */
224+ #[NoAdminRequired]
224225 public function getRecentFiles () {
225226 $ nodes = $ this ->userFolder ->getRecent (100 );
226227 $ files = $ this ->formatNodes ($ nodes );
@@ -231,11 +232,10 @@ public function getRecentFiles() {
231232 /**
232233 * Returns the current logged-in user's storage stats.
233234 *
234- * @NoAdminRequired
235- *
236235 * @param ?string $dir the directory to get the storage stats from
237236 * @return JSONResponse
238237 */
238+ #[NoAdminRequired]
239239 public function getStorageStats ($ dir = '/ ' ): JSONResponse {
240240 $ storageInfo = \OC_Helper::getStorageInfo ($ dir ?: '/ ' );
241241 $ response = new JSONResponse (['message ' => 'ok ' , 'data ' => $ storageInfo ]);
@@ -246,13 +246,12 @@ public function getStorageStats($dir = '/'): JSONResponse {
246246 /**
247247 * Set a user view config
248248 *
249- * @NoAdminRequired
250- *
251249 * @param string $view
252250 * @param string $key
253251 * @param string|bool $value
254252 * @return JSONResponse
255253 */
254+ #[NoAdminRequired]
256255 public function setViewConfig (string $ view , string $ key , $ value ): JSONResponse {
257256 try {
258257 $ this ->viewConfig ->setConfig ($ view , $ key , (string )$ value );
@@ -267,23 +266,21 @@ public function setViewConfig(string $view, string $key, $value): JSONResponse {
267266 /**
268267 * Get the user view config
269268 *
270- * @NoAdminRequired
271- *
272269 * @return JSONResponse
273270 */
271+ #[NoAdminRequired]
274272 public function getViewConfigs (): JSONResponse {
275273 return new JSONResponse (['message ' => 'ok ' , 'data ' => $ this ->viewConfig ->getConfigs ()]);
276274 }
277275
278276 /**
279277 * Set a user config
280278 *
281- * @NoAdminRequired
282- *
283279 * @param string $key
284280 * @param string|bool $value
285281 * @return JSONResponse
286282 */
283+ #[NoAdminRequired]
287284 public function setConfig (string $ key , $ value ): JSONResponse {
288285 try {
289286 $ this ->userConfig ->setConfig ($ key , (string )$ value );
@@ -298,23 +295,21 @@ public function setConfig(string $key, $value): JSONResponse {
298295 /**
299296 * Get the user config
300297 *
301- * @NoAdminRequired
302- *
303298 * @return JSONResponse
304299 */
300+ #[NoAdminRequired]
305301 public function getConfigs (): JSONResponse {
306302 return new JSONResponse (['message ' => 'ok ' , 'data ' => $ this ->userConfig ->getConfigs ()]);
307303 }
308304
309305 /**
310306 * Toggle default for showing/hiding hidden files
311307 *
312- * @NoAdminRequired
313- *
314308 * @param bool $value
315309 * @return Response
316310 * @throws \OCP\PreConditionNotMetException
317311 */
312+ #[NoAdminRequired]
318313 public function showHiddenFiles (bool $ value ): Response {
319314 $ this ->config ->setUserValue ($ this ->userSession ->getUser ()->getUID (), 'files ' , 'show_hidden ' , $ value ? '1 ' : '0 ' );
320315 return new Response ();
@@ -323,12 +318,11 @@ public function showHiddenFiles(bool $value): Response {
323318 /**
324319 * Toggle default for cropping preview images
325320 *
326- * @NoAdminRequired
327- *
328321 * @param bool $value
329322 * @return Response
330323 * @throws \OCP\PreConditionNotMetException
331324 */
325+ #[NoAdminRequired]
332326 public function cropImagePreviews (bool $ value ): Response {
333327 $ this ->config ->setUserValue ($ this ->userSession ->getUser ()->getUID (), 'files ' , 'crop_image_previews ' , $ value ? '1 ' : '0 ' );
334328 return new Response ();
@@ -337,32 +331,27 @@ public function cropImagePreviews(bool $value): Response {
337331 /**
338332 * Toggle default for files grid view
339333 *
340- * @NoAdminRequired
341- *
342334 * @param bool $show
343335 * @return Response
344336 * @throws \OCP\PreConditionNotMetException
345337 */
338+ #[NoAdminRequired]
346339 public function showGridView (bool $ show ): Response {
347340 $ this ->config ->setUserValue ($ this ->userSession ->getUser ()->getUID (), 'files ' , 'show_grid ' , $ show ? '1 ' : '0 ' );
348341 return new Response ();
349342 }
350343
351344 /**
352345 * Get default settings for the grid view
353- *
354- * @NoAdminRequired
355346 */
347+ #[NoAdminRequired]
356348 public function getGridView () {
357349 $ status = $ this ->config ->getUserValue ($ this ->userSession ->getUser ()->getUID (), 'files ' , 'show_grid ' , '0 ' ) === '1 ' ;
358350 return new JSONResponse (['gridview ' => $ status ]);
359351 }
360352
361- /**
362- * @NoAdminRequired
363- * @NoCSRFRequired
364- * @PublicPage
365- */
353+ #[PublicPage]
354+ #[NoCSRFRequired]
366355 #[OpenAPI(scope: OpenAPI::SCOPE_IGNORE )]
367356 public function serviceWorker (): StreamResponse {
368357 $ response = new StreamResponse (__DIR__ . '/../../../../dist/preview-service-worker.js ' );
0 commit comments