aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_status/lib
diff options
context:
space:
mode:
authorprovokateurin <kate@provokateurin.de>2024-01-10 12:35:33 +0100
committerprovokateurin <kate@provokateurin.de>2024-02-21 12:07:50 +0100
commit0117cd26940f2b0dcfd92ccf663bcf8853437193 (patch)
treea8330b27c66024c4d1047dec8b62102e7c4f67ca /apps/user_status/lib
parentdf6175ccb17cc6917c41fc6eb41b727ec81a920b (diff)
downloadnextcloud-server-0117cd26940f2b0dcfd92ccf663bcf8853437193.tar.gz
nextcloud-server-0117cd26940f2b0dcfd92ccf663bcf8853437193.zip
refactor(user_status): Switch to attribute based routing
Signed-off-by: provokateurin <kate@provokateurin.de>
Diffstat (limited to 'apps/user_status/lib')
-rw-r--r--apps/user_status/lib/Controller/HeartbeatController.php2
-rw-r--r--apps/user_status/lib/Controller/PredefinedStatusController.php2
-rw-r--r--apps/user_status/lib/Controller/StatusesController.php3
-rw-r--r--apps/user_status/lib/Controller/UserStatusController.php7
4 files changed, 14 insertions, 0 deletions
diff --git a/apps/user_status/lib/Controller/HeartbeatController.php b/apps/user_status/lib/Controller/HeartbeatController.php
index 79e12902495..f78dfe716e9 100644
--- a/apps/user_status/lib/Controller/HeartbeatController.php
+++ b/apps/user_status/lib/Controller/HeartbeatController.php
@@ -30,6 +30,7 @@ use OCA\UserStatus\Db\UserStatus;
use OCA\UserStatus\ResponseDefinitions;
use OCA\UserStatus\Service\StatusService;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\Attribute\ApiRoute;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\AppFramework\Utility\ITimeFactory;
@@ -81,6 +82,7 @@ class HeartbeatController extends OCSController {
* 204: User has no status to keep alive
* 400: Invalid status to update
*/
+ #[ApiRoute(verb: 'PUT', url: '/api/v1/heartbeat')]
public function heartbeat(string $status): DataResponse {
if (!\in_array($status, [IUserStatus::ONLINE, IUserStatus::AWAY], true)) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
diff --git a/apps/user_status/lib/Controller/PredefinedStatusController.php b/apps/user_status/lib/Controller/PredefinedStatusController.php
index 99acdca9f79..74952fd1247 100644
--- a/apps/user_status/lib/Controller/PredefinedStatusController.php
+++ b/apps/user_status/lib/Controller/PredefinedStatusController.php
@@ -29,6 +29,7 @@ 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\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\IRequest;
@@ -66,6 +67,7 @@ class PredefinedStatusController extends OCSController {
*
* 200: Predefined statuses returned
*/
+ #[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) {
diff --git a/apps/user_status/lib/Controller/StatusesController.php b/apps/user_status/lib/Controller/StatusesController.php
index b506a691a61..b2539af8689 100644
--- a/apps/user_status/lib/Controller/StatusesController.php
+++ b/apps/user_status/lib/Controller/StatusesController.php
@@ -32,6 +32,7 @@ use OCA\UserStatus\ResponseDefinitions;
use OCA\UserStatus\Service\StatusService;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\Attribute\ApiRoute;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\AppFramework\OCSController;
@@ -72,6 +73,7 @@ class StatusesController extends OCSController {
*
* 200: Statuses returned
*/
+ #[ApiRoute(verb: 'GET', url: '/api/v1/statuses')]
public function findAll(?int $limit = null, ?int $offset = null): DataResponse {
$allStatuses = $this->service->findAll($limit, $offset);
@@ -91,6 +93,7 @@ class StatusesController extends OCSController {
*
* 200: Status returned
*/
+ #[ApiRoute(verb: 'GET', url: '/api/v1/statuses/{userId}')]
public function find(string $userId): DataResponse {
try {
$userStatus = $this->service->findByUserId($userId);
diff --git a/apps/user_status/lib/Controller/UserStatusController.php b/apps/user_status/lib/Controller/UserStatusController.php
index d06370a19ea..736c4e772ca 100644
--- a/apps/user_status/lib/Controller/UserStatusController.php
+++ b/apps/user_status/lib/Controller/UserStatusController.php
@@ -39,6 +39,7 @@ use OCA\UserStatus\ResponseDefinitions;
use OCA\UserStatus\Service\StatusService;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\Attribute\ApiRoute;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSBadRequestException;
use OCP\AppFramework\OCS\OCSNotFoundException;
@@ -72,6 +73,7 @@ class UserStatusController extends OCSController {
*
* 200: The status was found successfully
*/
+ #[ApiRoute(verb: 'GET', url: '/api/v1/user_status')]
public function getStatus(): DataResponse {
try {
$this->calendarStatusService->processCalendarStatus($this->userId);
@@ -94,6 +96,7 @@ class UserStatusController extends OCSController {
*
* 200: The status was updated successfully
*/
+ #[ApiRoute(verb: 'PUT', url: '/api/v1/user_status/status')]
public function setStatus(string $statusType): DataResponse {
try {
$status = $this->service->setStatus($this->userId, $statusType, null, true);
@@ -118,6 +121,7 @@ class UserStatusController extends OCSController {
*
* 200: The message was updated successfully
*/
+ #[ApiRoute(verb: 'PUT', url: '/api/v1/user_status/message/predefined')]
public function setPredefinedMessage(string $messageId,
?int $clearAt): DataResponse {
try {
@@ -146,6 +150,7 @@ class UserStatusController extends OCSController {
*
* 200: The message was updated successfully
*/
+ #[ApiRoute(verb: 'PUT', url: '/api/v1/user_status/message/custom')]
public function setCustomMessage(?string $statusIcon,
?string $message,
?int $clearAt): DataResponse {
@@ -179,6 +184,7 @@ class UserStatusController extends OCSController {
*
* 200: Message cleared successfully
*/
+ #[ApiRoute(verb: 'DELETE', url: '/api/v1/user_status/message')]
public function clearMessage(): DataResponse {
$this->service->clearMessage($this->userId);
return new DataResponse([]);
@@ -195,6 +201,7 @@ class UserStatusController extends OCSController {
*
* 200: Status reverted
*/
+ #[ApiRoute(verb: 'DELETE', url: '/api/v1/user_status/revert/{messageId}')]
public function revertStatus(string $messageId): DataResponse {
$backupStatus = $this->service->revertUserStatus($this->userId, $messageId, true);
if ($backupStatus) {