aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_status/lib/Controller/PredefinedStatusController.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_status/lib/Controller/PredefinedStatusController.php')
-rw-r--r--apps/user_status/lib/Controller/PredefinedStatusController.php44
1 files changed, 13 insertions, 31 deletions
diff --git a/apps/user_status/lib/Controller/PredefinedStatusController.php b/apps/user_status/lib/Controller/PredefinedStatusController.php
index 99acdca9f79..70262d1108a 100644
--- a/apps/user_status/lib/Controller/PredefinedStatusController.php
+++ b/apps/user_status/lib/Controller/PredefinedStatusController.php
@@ -3,32 +3,16 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020, Georg Ehrke
- *
- * @author Georg Ehrke <oc.list@georgehrke.com>
- * @author Kate Döen <kate.doeen@nextcloud.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\UserStatus\Controller;
use OCA\UserStatus\ResponseDefinitions;
use OCA\UserStatus\Service\PredefinedStatusService;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\Attribute\ApiRoute;
+use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\IRequest;
@@ -40,9 +24,6 @@ use OCP\IRequest;
*/
class PredefinedStatusController extends OCSController {
- /** @var PredefinedStatusService */
- private $predefinedStatusService;
-
/**
* AStatusController constructor.
*
@@ -50,26 +31,27 @@ class PredefinedStatusController extends OCSController {
* @param IRequest $request
* @param PredefinedStatusService $predefinedStatusService
*/
- public function __construct(string $appName,
+ public function __construct(
+ string $appName,
IRequest $request,
- PredefinedStatusService $predefinedStatusService) {
+ private PredefinedStatusService $predefinedStatusService,
+ ) {
parent::__construct($appName, $request);
- $this->predefinedStatusService = $predefinedStatusService;
}
/**
* Get all predefined messages
*
- * @NoAdminRequired
- *
- * @return DataResponse<Http::STATUS_OK, UserStatusPredefined[], array{}>
+ * @return DataResponse<Http::STATUS_OK, list<UserStatusPredefined>, array{}>
*
* 200: Predefined statuses returned
*/
+ #[NoAdminRequired]
+ #[ApiRoute(verb: 'GET', url: '/api/v1/predefined_statuses/')]
public function findAll():DataResponse {
// Filtering out the invisible one, that should only be set by API
- return new DataResponse(array_filter($this->predefinedStatusService->getDefaultStatuses(), function (array $status) {
+ return new DataResponse(array_values(array_filter($this->predefinedStatusService->getDefaultStatuses(), function (array $status) {
return !array_key_exists('visible', $status) || $status['visible'] === true;
- }));
+ })));
}
}