Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions apps/user_status/lib/Controller/HeartbeatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use OCA\UserStatus\Service\StatusService;
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\AppFramework\Utility\ITimeFactory;
Expand Down Expand Up @@ -55,15 +56,14 @@ public function __construct(string $appName,
/**
* Keep the status alive
*
* @NoAdminRequired
*
* @param string $status Only online, away
*
* @return DataResponse<Http::STATUS_OK, UserStatusPrivate, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NO_CONTENT, array<empty>, array{}>
* 200: Status successfully updated
* 204: User has no status to keep alive
* 400: Invalid status to update
*/
#[NoAdminRequired]
#[ApiRoute(verb: 'PUT', url: '/api/v1/heartbeat')]
public function heartbeat(string $status): DataResponse {
if (!\in_array($status, [IUserStatus::ONLINE, IUserStatus::AWAY], true)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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;
Expand Down Expand Up @@ -43,12 +44,11 @@ public function __construct(string $appName,
/**
* Get all predefined messages
*
* @NoAdminRequired
*
* @return DataResponse<Http::STATUS_OK, 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
Expand Down
7 changes: 3 additions & 4 deletions apps/user_status/lib/Controller/StatusesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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\OCSNotFoundException;
use OCP\AppFramework\OCSController;
Expand Down Expand Up @@ -46,14 +47,13 @@ public function __construct(string $appName,
/**
* Find statuses of users
*
* @NoAdminRequired
*
* @param int|null $limit Maximum number of statuses to find
* @param int|null $offset Offset for finding statuses
* @return DataResponse<Http::STATUS_OK, UserStatusPublic[], array{}>
*
* 200: Statuses returned
*/
#[NoAdminRequired]
#[ApiRoute(verb: 'GET', url: '/api/v1/statuses')]
public function findAll(?int $limit = null, ?int $offset = null): DataResponse {
$allStatuses = $this->service->findAll($limit, $offset);
Expand All @@ -66,14 +66,13 @@ public function findAll(?int $limit = null, ?int $offset = null): DataResponse {
/**
* Find the status of a user
*
* @NoAdminRequired
*
* @param string $userId ID of the user
* @return DataResponse<Http::STATUS_OK, UserStatusPublic, array{}>
* @throws OCSNotFoundException The user was not found
*
* 200: Status returned
*/
#[NoAdminRequired]
#[ApiRoute(verb: 'GET', url: '/api/v1/statuses/{userId}')]
public function find(string $userId): DataResponse {
try {
Expand Down
19 changes: 7 additions & 12 deletions apps/user_status/lib/Controller/UserStatusController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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;
Expand All @@ -46,13 +47,12 @@ public function __construct(
/**
* 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 {
Expand All @@ -68,14 +68,13 @@ public function getStatus(): DataResponse {
/**
* 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 {
Expand All @@ -92,15 +91,14 @@ public function setStatus(string $statusType): DataResponse {
/**
* 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{}>
* @throws OCSBadRequestException The clearAt or message-id is invalid
*
* 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 {
Expand All @@ -120,8 +118,6 @@ public function setPredefinedMessage(string $messageId,
/**
* 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
Expand All @@ -130,6 +126,7 @@ public function setPredefinedMessage(string $messageId,
*
* 200: The message was updated successfully
*/
#[NoAdminRequired]
#[ApiRoute(verb: 'PUT', url: '/api/v1/user_status/message/custom')]
public function setCustomMessage(?string $statusIcon,
?string $message,
Expand Down Expand Up @@ -158,12 +155,11 @@ public function setCustomMessage(?string $statusIcon,
/**
* 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);
Expand All @@ -173,14 +169,13 @@ public function clearMessage(): DataResponse {
/**
* 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);
Expand Down