88 * @author Georg Ehrke <oc.list@georgehrke.com>
99 * @author Joas Schilling <coding@schilljs.com>
1010 * @author Simon Spannagel <simonspa@kth.se>
11+ * @author Kate Döen <kate.doeen@nextcloud.com>
1112 *
1213 * @license GNU AGPL version 3 or any later version
1314 *
3334use OCA \UserStatus \Exception \InvalidStatusIconException ;
3435use OCA \UserStatus \Exception \InvalidStatusTypeException ;
3536use OCA \UserStatus \Exception \StatusMessageTooLongException ;
37+ use OCA \UserStatus \ResponseDefinitions ;
3638use OCA \UserStatus \Service \StatusService ;
3739use OCP \AppFramework \Db \DoesNotExistException ;
40+ use OCP \AppFramework \Http ;
3841use OCP \AppFramework \Http \DataResponse ;
3942use OCP \AppFramework \OCS \OCSBadRequestException ;
4043use OCP \AppFramework \OCS \OCSNotFoundException ;
4144use OCP \AppFramework \OCSController ;
4245use OCP \ILogger ;
4346use OCP \IRequest ;
4447
48+ /**
49+ * @psalm-import-type UserStatusPrivate from ResponseDefinitions
50+ */
4551class UserStatusController extends OCSController {
4652
4753 /** @var string */
@@ -74,10 +80,14 @@ public function __construct(string $appName,
7480 }
7581
7682 /**
83+ * Get the status of the current user
84+ *
7785 * @NoAdminRequired
7886 *
79- * @return DataResponse
80- * @throws OCSNotFoundException
87+ * @return DataResponse<Http::STATUS_OK, UserStatusPrivate, array{}>
88+ * @throws OCSNotFoundException The user was not found
89+ *
90+ * 200: The status was found successfully
8191 */
8292 public function getStatus (): DataResponse {
8393 try {
@@ -90,11 +100,15 @@ public function getStatus(): DataResponse {
90100 }
91101
92102 /**
103+ * Update the status type of the current user
104+ *
93105 * @NoAdminRequired
94106 *
95- * @param string $statusType
96- * @return DataResponse
97- * @throws OCSBadRequestException
107+ * @param string $statusType The new status type
108+ * @return DataResponse<Http::STATUS_OK, UserStatusPrivate, array{}>
109+ * @throws OCSBadRequestException The status type is invalid
110+ *
111+ * 200: The status was updated successfully
98112 */
99113 public function setStatus (string $ statusType ): DataResponse {
100114 try {
@@ -109,12 +123,16 @@ public function setStatus(string $statusType): DataResponse {
109123 }
110124
111125 /**
126+ * Set the message to a predefined message for the current user
127+ *
112128 * @NoAdminRequired
113129 *
114- * @param string $messageId
115- * @param int|null $clearAt
116- * @return DataResponse
117- * @throws OCSBadRequestException
130+ * @param string $messageId ID of the predefined message
131+ * @param int|null $clearAt When the message should be cleared
132+ * @return DataResponse<Http::STATUS_OK, UserStatusPrivate, array{}>
133+ * @throws OCSBadRequestException The clearAt or message-id is invalid
134+ *
135+ * 200: The message was updated successfully
118136 */
119137 public function setPredefinedMessage (string $ messageId ,
120138 ?int $ clearAt ): DataResponse {
@@ -132,13 +150,17 @@ public function setPredefinedMessage(string $messageId,
132150 }
133151
134152 /**
153+ * Set the message to a custom message for the current user
154+ *
135155 * @NoAdminRequired
136156 *
137- * @param string|null $statusIcon
138- * @param string|null $message
139- * @param int|null $clearAt
140- * @return DataResponse
141- * @throws OCSBadRequestException
157+ * @param string|null $statusIcon Icon of the status
158+ * @param string|null $message Message of the status
159+ * @param int|null $clearAt When the message should be cleared
160+ * @return DataResponse<Http::STATUS_OK, UserStatusPrivate, array{}>
161+ * @throws OCSBadRequestException The clearAt or icon is invalid or the message is too long
162+ *
163+ * 200: The message was updated successfully
142164 */
143165 public function setCustomMessage (?string $ statusIcon ,
144166 ?string $ message ,
@@ -165,19 +187,27 @@ public function setCustomMessage(?string $statusIcon,
165187 }
166188
167189 /**
190+ * Clear the message of the current user
191+ *
168192 * @NoAdminRequired
169193 *
170- * @return DataResponse
194+ * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
171195 */
172196 public function clearMessage (): DataResponse {
173197 $ this ->service ->clearMessage ($ this ->userId );
174198 return new DataResponse ([]);
175199 }
176200
177201 /**
202+ * Revert the status to the previous status
203+ *
178204 * @NoAdminRequired
179205 *
180- * @return DataResponse
206+ * @param string $messageId ID of the message to delete
207+ *
208+ * @return DataResponse<Http::STATUS_OK, UserStatusPrivate|array<empty>, array{}>
209+ *
210+ * 200: Status reverted
181211 */
182212 public function revertStatus (string $ messageId ): DataResponse {
183213 $ backupStatus = $ this ->service ->revertUserStatus ($ this ->userId , $ messageId , true );
@@ -189,7 +219,7 @@ public function revertStatus(string $messageId): DataResponse {
189219
190220 /**
191221 * @param UserStatus $status
192- * @return array
222+ * @return UserStatusPrivate
193223 */
194224 private function formatStatus (UserStatus $ status ): array {
195225 return [
0 commit comments