1111use OCA \WeatherStatus \ResponseDefinitions ;
1212use OCA \WeatherStatus \Service \WeatherStatusService ;
1313use OCP \AppFramework \Http ;
14+ use OCP \AppFramework \Http \Attribute \NoAdminRequired ;
1415use OCP \AppFramework \Http \DataResponse ;
1516use OCP \AppFramework \OCSController ;
1617use OCP \IRequest ;
@@ -33,21 +34,18 @@ public function __construct(
3334 }
3435
3536 /**
36- * @NoAdminRequired
37- *
3837 * Try to use the address set in user personal settings as weather location
3938 *
4039 * @return DataResponse<Http::STATUS_OK, WeatherStatusLocationWithSuccess, array{}>
4140 *
4241 * 200: Address updated
4342 */
43+ #[NoAdminRequired]
4444 public function usePersonalAddress (): DataResponse {
4545 return new DataResponse ($ this ->service ->usePersonalAddress ());
4646 }
4747
4848 /**
49- * @NoAdminRequired
50- *
5149 * Change the weather status mode. There are currently 2 modes:
5250 * - ask the browser
5351 * - use the user defined address
@@ -57,13 +55,12 @@ public function usePersonalAddress(): DataResponse {
5755 *
5856 * 200: Weather status mode updated
5957 */
58+ #[NoAdminRequired]
6059 public function setMode (int $ mode ): DataResponse {
6160 return new DataResponse ($ this ->service ->setMode ($ mode ));
6261 }
6362
6463 /**
65- * @NoAdminRequired
66- *
6764 * Set address and resolve it to get coordinates
6865 * or directly set coordinates and get address with reverse geocoding
6966 *
@@ -74,35 +71,34 @@ public function setMode(int $mode): DataResponse {
7471 *
7572 * 200: Location updated
7673 */
74+ #[NoAdminRequired]
7775 public function setLocation (?string $ address , ?float $ lat , ?float $ lon ): DataResponse {
7876 $ currentWeather = $ this ->service ->setLocation ($ address , $ lat , $ lon );
7977 return new DataResponse ($ currentWeather );
8078 }
8179
8280 /**
83- * @NoAdminRequired
84- *
8581 * Get stored user location
8682 *
8783 * @return DataResponse<Http::STATUS_OK, WeatherStatusLocationWithMode, array{}>
8884 *
8985 * 200: Location returned
9086 */
87+ #[NoAdminRequired]
9188 public function getLocation (): DataResponse {
9289 $ location = $ this ->service ->getLocation ();
9390 return new DataResponse ($ location );
9491 }
9592
9693 /**
97- * @NoAdminRequired
98- *
9994 * Get forecast for current location
10095 *
10196 * @return DataResponse<Http::STATUS_OK, WeatherStatusForecast[]|array{error: string}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, WeatherStatusSuccess, array{}>
10297 *
10398 * 200: Forecast returned
10499 * 404: Forecast not found
105100 */
101+ #[NoAdminRequired]
106102 public function getForecast (): DataResponse {
107103 $ forecast = $ this ->service ->getForecast ();
108104 if (isset ($ forecast ['success ' ]) && $ forecast ['success ' ] === false ) {
@@ -113,28 +109,26 @@ public function getForecast(): DataResponse {
113109 }
114110
115111 /**
116- * @NoAdminRequired
117- *
118112 * Get favorites list
119113 *
120114 * @return DataResponse<Http::STATUS_OK, string[], array{}>
121115 *
122116 * 200: Favorites returned
123117 */
118+ #[NoAdminRequired]
124119 public function getFavorites (): DataResponse {
125120 return new DataResponse ($ this ->service ->getFavorites ());
126121 }
127122
128123 /**
129- * @NoAdminRequired
130- *
131124 * Set favorites list
132125 *
133126 * @param string[] $favorites Favorite addresses
134127 * @return DataResponse<Http::STATUS_OK, WeatherStatusSuccess, array{}>
135128 *
136129 * 200: Favorites updated
137130 */
131+ #[NoAdminRequired]
138132 public function setFavorites (array $ favorites ): DataResponse {
139133 return new DataResponse ($ this ->service ->setFavorites ($ favorites ));
140134 }
0 commit comments