Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(weather_status): Replace security annotations with respective attributes #46824

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions apps/weather_status/lib/Controller/WeatherStatusController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use OCA\WeatherStatus\ResponseDefinitions;
use OCA\WeatherStatus\Service\WeatherStatusService;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\IRequest;
Expand All @@ -33,21 +34,18 @@ public function __construct(
}

/**
* @NoAdminRequired
*
* Try to use the address set in user personal settings as weather location
*
* @return DataResponse<Http::STATUS_OK, WeatherStatusLocationWithSuccess, array{}>
*
* 200: Address updated
*/
#[NoAdminRequired]
public function usePersonalAddress(): DataResponse {
return new DataResponse($this->service->usePersonalAddress());
}

/**
* @NoAdminRequired
*
* Change the weather status mode. There are currently 2 modes:
* - ask the browser
* - use the user defined address
Expand All @@ -57,13 +55,12 @@ public function usePersonalAddress(): DataResponse {
*
* 200: Weather status mode updated
*/
#[NoAdminRequired]
public function setMode(int $mode): DataResponse {
return new DataResponse($this->service->setMode($mode));
}

/**
* @NoAdminRequired
*
* Set address and resolve it to get coordinates
* or directly set coordinates and get address with reverse geocoding
*
Expand All @@ -74,35 +71,34 @@ public function setMode(int $mode): DataResponse {
*
* 200: Location updated
*/
#[NoAdminRequired]
public function setLocation(?string $address, ?float $lat, ?float $lon): DataResponse {
$currentWeather = $this->service->setLocation($address, $lat, $lon);
return new DataResponse($currentWeather);
}

/**
* @NoAdminRequired
*
* Get stored user location
*
* @return DataResponse<Http::STATUS_OK, WeatherStatusLocationWithMode, array{}>
*
* 200: Location returned
*/
#[NoAdminRequired]
public function getLocation(): DataResponse {
$location = $this->service->getLocation();
return new DataResponse($location);
}

/**
* @NoAdminRequired
*
* Get forecast for current location
*
* @return DataResponse<Http::STATUS_OK, WeatherStatusForecast[]|array{error: string}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, WeatherStatusSuccess, array{}>
*
* 200: Forecast returned
* 404: Forecast not found
*/
#[NoAdminRequired]
public function getForecast(): DataResponse {
$forecast = $this->service->getForecast();
if (isset($forecast['success']) && $forecast['success'] === false) {
Expand All @@ -113,28 +109,26 @@ public function getForecast(): DataResponse {
}

/**
* @NoAdminRequired
*
* Get favorites list
*
* @return DataResponse<Http::STATUS_OK, string[], array{}>
*
* 200: Favorites returned
*/
#[NoAdminRequired]
public function getFavorites(): DataResponse {
return new DataResponse($this->service->getFavorites());
}

/**
* @NoAdminRequired
*
* Set favorites list
*
* @param string[] $favorites Favorite addresses
* @return DataResponse<Http::STATUS_OK, WeatherStatusSuccess, array{}>
*
* 200: Favorites updated
*/
#[NoAdminRequired]
public function setFavorites(array $favorites): DataResponse {
return new DataResponse($this->service->setFavorites($favorites));
}
Expand Down
Loading