14
14
* @author Robin Appelman <robin@icewind.nl>
15
15
* @author Roeland Jago Douma <roeland@famdouma.nl>
16
16
* @author Tom Needham <tom@owncloud.com>
17
+ * @author Kate Döen <kate.doeen@nextcloud.com>
17
18
*
18
19
* @license AGPL-3.0
19
20
*
32
33
*/
33
34
namespace OCA \Provisioning_API \Controller ;
34
35
36
+ use OCA \Provisioning_API \ResponseDefinitions ;
35
37
use OCP \Accounts \IAccountManager ;
38
+ use OCP \AppFramework \Http ;
36
39
use OCP \AppFramework \Http \DataResponse ;
37
40
use OCP \AppFramework \OCS \OCSException ;
38
41
use OCP \AppFramework \OCS \OCSForbiddenException ;
48
51
use OCP \L10N \IFactory ;
49
52
use Psr \Log \LoggerInterface ;
50
53
54
+ /**
55
+ * @psalm-import-type GroupDetails from ResponseDefinitions
56
+ * @psalm-import-type UserDetails from ResponseDefinitions
57
+ */
51
58
class GroupsController extends AUserData {
52
59
53
60
/** @var LoggerInterface */
@@ -83,7 +90,7 @@ public function __construct(string $appName,
83
90
* @param string $search
84
91
* @param int $limit
85
92
* @param int $offset
86
- * @return DataResponse
93
+ * @return DataResponse<array{groups: string[]}, Http::STATUS_OK>
87
94
*/
88
95
public function getGroups (string $ search = '' , int $ limit = null , int $ offset = 0 ): DataResponse {
89
96
$ groups = $ this ->groupManager ->search ($ search , $ limit , $ offset );
@@ -104,7 +111,7 @@ public function getGroups(string $search = '', int $limit = null, int $offset =
104
111
* @param string $search
105
112
* @param int $limit
106
113
* @param int $offset
107
- * @return DataResponse
114
+ * @return DataResponse<array{groups: GroupDetails[]}, Http::STATUS_OK>
108
115
*/
109
116
public function getGroupsDetails (string $ search = '' , int $ limit = null , int $ offset = 0 ): DataResponse {
110
117
$ groups = $ this ->groupManager ->search ($ search , $ limit , $ offset );
@@ -127,7 +134,7 @@ public function getGroupsDetails(string $search = '', int $limit = null, int $of
127
134
* @NoAdminRequired
128
135
*
129
136
* @param string $groupId
130
- * @return DataResponse
137
+ * @return DataResponse<array{users: string[]}, Http::STATUS_OK>
131
138
* @throws OCSException
132
139
*
133
140
* @deprecated 14 Use getGroupUsers
@@ -142,8 +149,10 @@ public function getGroup(string $groupId): DataResponse {
142
149
* @NoAdminRequired
143
150
*
144
151
* @param string $groupId
145
- * @return DataResponse
152
+ * @return DataResponse<array{users: string[]}, Http::STATUS_OK>
146
153
* @throws OCSException
154
+ * @throws OCSNotFoundException
155
+ * @throws OCSForbiddenException
147
156
*/
148
157
public function getGroupUsers (string $ groupId ): DataResponse {
149
158
$ groupId = urldecode ($ groupId );
@@ -167,6 +176,7 @@ public function getGroupUsers(string $groupId): DataResponse {
167
176
/** @var IUser $user */
168
177
return $ user ->getUID ();
169
178
}, $ users );
179
+ /** @var string[] $users */
170
180
$ users = array_values ($ users );
171
181
return new DataResponse (['users ' => $ users ]);
172
182
}
@@ -183,7 +193,8 @@ public function getGroupUsers(string $groupId): DataResponse {
183
193
* @param string $search
184
194
* @param int $limit
185
195
* @param int $offset
186
- * @return DataResponse
196
+ *
197
+ * @return DataResponse<array{users: array<string, UserDetails|array{id: string}>}, Http::STATUS_OK>
187
198
* @throws OCSException
188
199
*/
189
200
public function getGroupUsersDetails (string $ groupId , string $ search = '' , int $ limit = null , int $ offset = 0 ): DataResponse {
@@ -210,7 +221,7 @@ public function getGroupUsersDetails(string $groupId, string $search = '', int $
210
221
$ userId = (string )$ user ->getUID ();
211
222
$ userData = $ this ->getUserData ($ userId );
212
223
// Do not insert empty entry
213
- if (! empty ( $ userData) ) {
224
+ if ($ userData != null ) {
214
225
$ usersDetails [$ userId ] = $ userData ;
215
226
} else {
216
227
// Logged user does not have permissions to see this user
@@ -234,7 +245,7 @@ public function getGroupUsersDetails(string $groupId, string $search = '', int $
234
245
*
235
246
* @param string $groupid
236
247
* @param string $displayname
237
- * @return DataResponse
248
+ * @return DataResponse<array, Http::STATUS_OK>
238
249
* @throws OCSException
239
250
*/
240
251
public function addGroup (string $ groupid , string $ displayname = '' ): DataResponse {
@@ -263,7 +274,7 @@ public function addGroup(string $groupid, string $displayname = ''): DataRespons
263
274
* @param string $groupId
264
275
* @param string $key
265
276
* @param string $value
266
- * @return DataResponse
277
+ * @return DataResponse<array, Http::STATUS_OK>
267
278
* @throws OCSException
268
279
*/
269
280
public function updateGroup (string $ groupId , string $ key , string $ value ): DataResponse {
@@ -285,7 +296,7 @@ public function updateGroup(string $groupId, string $key, string $value): DataRe
285
296
* @PasswordConfirmationRequired
286
297
*
287
298
* @param string $groupId
288
- * @return DataResponse
299
+ * @return DataResponse<array, Http::STATUS_OK>
289
300
* @throws OCSException
290
301
*/
291
302
public function deleteGroup (string $ groupId ): DataResponse {
@@ -304,7 +315,7 @@ public function deleteGroup(string $groupId): DataResponse {
304
315
305
316
/**
306
317
* @param string $groupId
307
- * @return DataResponse
318
+ * @return DataResponse<string[], Http::STATUS_OK>
308
319
* @throws OCSException
309
320
*/
310
321
public function getSubAdminsOfGroup (string $ groupId ): DataResponse {
@@ -317,6 +328,7 @@ public function getSubAdminsOfGroup(string $groupId): DataResponse {
317
328
/** @var IUser[] $subadmins */
318
329
$ subadmins = $ this ->groupManager ->getSubAdmin ()->getGroupsSubAdmins ($ targetGroup );
319
330
// New class returns IUser[] so convert back
331
+ /** @var string[] $uids */
320
332
$ uids = [];
321
333
foreach ($ subadmins as $ user ) {
322
334
$ uids [] = $ user ->getUID ();
0 commit comments