|
|
|
|
@ -20,6 +20,7 @@ use OCA\UserStatus\Service\StatusService;
|
|
|
|
|
use OCP\AppFramework\Db\DoesNotExistException;
|
|
|
|
|
use OCP\AppFramework\Http;
|
|
|
|
|
use OCP\AppFramework\Http\Attribute\ApiRoute;
|
|
|
|
|
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
|
|
|
|
use OCP\AppFramework\Http\DataResponse;
|
|
|
|
|
use OCP\AppFramework\OCS\OCSBadRequestException;
|
|
|
|
|
use OCP\AppFramework\OCS\OCSNotFoundException;
|
|
|
|
|
@ -46,13 +47,12 @@ class UserStatusController extends OCSController {
|
|
|
|
|
/**
|
|
|
|
|
* Get the status of the current user
|
|
|
|
|
*
|
|
|
|
|
* @NoAdminRequired
|
|
|
|
|
*
|
|
|
|
|
* @return DataResponse<Http::STATUS_OK, UserStatusPrivate, array{}>
|
|
|
|
|
* @throws OCSNotFoundException The user was not found
|
|
|
|
|
*
|
|
|
|
|
* 200: The status was found successfully
|
|
|
|
|
*/
|
|
|
|
|
#[NoAdminRequired]
|
|
|
|
|
#[ApiRoute(verb: 'GET', url: '/api/v1/user_status')]
|
|
|
|
|
public function getStatus(): DataResponse {
|
|
|
|
|
try {
|
|
|
|
|
@ -68,14 +68,13 @@ class UserStatusController extends OCSController {
|
|
|
|
|
/**
|
|
|
|
|
* Update the status type of the current user
|
|
|
|
|
*
|
|
|
|
|
* @NoAdminRequired
|
|
|
|
|
*
|
|
|
|
|
* @param string $statusType The new status type
|
|
|
|
|
* @return DataResponse<Http::STATUS_OK, UserStatusPrivate, array{}>
|
|
|
|
|
* @throws OCSBadRequestException The status type is invalid
|
|
|
|
|
*
|
|
|
|
|
* 200: The status was updated successfully
|
|
|
|
|
*/
|
|
|
|
|
#[NoAdminRequired]
|
|
|
|
|
#[ApiRoute(verb: 'PUT', url: '/api/v1/user_status/status')]
|
|
|
|
|
public function setStatus(string $statusType): DataResponse {
|
|
|
|
|
try {
|
|
|
|
|
@ -92,8 +91,6 @@ class UserStatusController extends OCSController {
|
|
|
|
|
/**
|
|
|
|
|
* Set the message to a predefined message for the current user
|
|
|
|
|
*
|
|
|
|
|
* @NoAdminRequired
|
|
|
|
|
*
|
|
|
|
|
* @param string $messageId ID of the predefined message
|
|
|
|
|
* @param int|null $clearAt When the message should be cleared
|
|
|
|
|
* @return DataResponse<Http::STATUS_OK, UserStatusPrivate, array{}>
|
|
|
|
|
@ -101,6 +98,7 @@ class UserStatusController extends OCSController {
|
|
|
|
|
*
|
|
|
|
|
* 200: The message was updated successfully
|
|
|
|
|
*/
|
|
|
|
|
#[NoAdminRequired]
|
|
|
|
|
#[ApiRoute(verb: 'PUT', url: '/api/v1/user_status/message/predefined')]
|
|
|
|
|
public function setPredefinedMessage(string $messageId,
|
|
|
|
|
?int $clearAt): DataResponse {
|
|
|
|
|
@ -120,8 +118,6 @@ class UserStatusController extends OCSController {
|
|
|
|
|
/**
|
|
|
|
|
* Set the message to a custom message for the current user
|
|
|
|
|
*
|
|
|
|
|
* @NoAdminRequired
|
|
|
|
|
*
|
|
|
|
|
* @param string|null $statusIcon Icon of the status
|
|
|
|
|
* @param string|null $message Message of the status
|
|
|
|
|
* @param int|null $clearAt When the message should be cleared
|
|
|
|
|
@ -130,6 +126,7 @@ class UserStatusController extends OCSController {
|
|
|
|
|
*
|
|
|
|
|
* 200: The message was updated successfully
|
|
|
|
|
*/
|
|
|
|
|
#[NoAdminRequired]
|
|
|
|
|
#[ApiRoute(verb: 'PUT', url: '/api/v1/user_status/message/custom')]
|
|
|
|
|
public function setCustomMessage(?string $statusIcon,
|
|
|
|
|
?string $message,
|
|
|
|
|
@ -158,12 +155,11 @@ class UserStatusController extends OCSController {
|
|
|
|
|
/**
|
|
|
|
|
* Clear the message of the current user
|
|
|
|
|
*
|
|
|
|
|
* @NoAdminRequired
|
|
|
|
|
*
|
|
|
|
|
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
|
|
|
|
|
*
|
|
|
|
|
* 200: Message cleared successfully
|
|
|
|
|
*/
|
|
|
|
|
#[NoAdminRequired]
|
|
|
|
|
#[ApiRoute(verb: 'DELETE', url: '/api/v1/user_status/message')]
|
|
|
|
|
public function clearMessage(): DataResponse {
|
|
|
|
|
$this->service->clearMessage($this->userId);
|
|
|
|
|
@ -173,14 +169,13 @@ class UserStatusController extends OCSController {
|
|
|
|
|
/**
|
|
|
|
|
* Revert the status to the previous status
|
|
|
|
|
*
|
|
|
|
|
* @NoAdminRequired
|
|
|
|
|
*
|
|
|
|
|
* @param string $messageId ID of the message to delete
|
|
|
|
|
*
|
|
|
|
|
* @return DataResponse<Http::STATUS_OK, UserStatusPrivate|array<empty>, array{}>
|
|
|
|
|
*
|
|
|
|
|
* 200: Status reverted
|
|
|
|
|
*/
|
|
|
|
|
#[NoAdminRequired]
|
|
|
|
|
#[ApiRoute(verb: 'DELETE', url: '/api/v1/user_status/revert/{messageId}')]
|
|
|
|
|
public function revertStatus(string $messageId): DataResponse {
|
|
|
|
|
$backupStatus = $this->service->revertUserStatus($this->userId, $messageId, true);
|
|
|
|
|
|