Skip to content

Commit b0429e7

Browse files
Merge pull request #45270 from nextcloud/refactor/provisioning_api/type-scopes
2 parents 4dc73b3 + aff7798 commit b0429e7

File tree

5 files changed

+73
-42
lines changed

5 files changed

+73
-42
lines changed

apps/provisioning_api/lib/ResponseDefinitions.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,51 +35,53 @@
3535
* used?: float|int,
3636
* }
3737
*
38+
* @psalm-type Provisioning_APIUserDetailsScope = 'v2-private'|'v2-local'|'v2-federated'|'v2-published'|'private'|'contacts'|'public'
39+
*
3840
* @psalm-type Provisioning_APIUserDetails = array{
3941
* additional_mail: string[],
40-
* additional_mailScope?: string[],
42+
* additional_mailScope?: Provisioning_APIUserDetailsScope[],
4143
* address: string,
42-
* addressScope?: string,
43-
* avatarScope?: string,
44+
* addressScope?: Provisioning_APIUserDetailsScope,
45+
* avatarScope?: Provisioning_APIUserDetailsScope,
4446
* backend: string,
4547
* backendCapabilities: array{
4648
* setDisplayName: bool,
4749
* setPassword: bool
4850
* },
4951
* biography: string,
50-
* biographyScope?: string,
52+
* biographyScope?: Provisioning_APIUserDetailsScope,
5153
* display-name: string,
5254
* displayname: string,
53-
* displaynameScope?: string,
55+
* displaynameScope?: Provisioning_APIUserDetailsScope,
5456
* email: ?string,
55-
* emailScope?: string,
57+
* emailScope?: Provisioning_APIUserDetailsScope,
5658
* enabled?: bool,
5759
* fediverse: string,
58-
* fediverseScope?: string,
60+
* fediverseScope?: Provisioning_APIUserDetailsScope,
5961
* groups: string[],
6062
* headline: string,
61-
* headlineScope?: string,
63+
* headlineScope?: Provisioning_APIUserDetailsScope,
6264
* id: string,
6365
* language: string,
6466
* lastLogin: int,
6567
* locale: string,
6668
* manager: string,
6769
* notify_email: ?string,
6870
* organisation: string,
69-
* organisationScope?: string,
71+
* organisationScope?: Provisioning_APIUserDetailsScope,
7072
* phone: string,
71-
* phoneScope?: string,
73+
* phoneScope?: Provisioning_APIUserDetailsScope,
7274
* profile_enabled: string,
73-
* profile_enabledScope?: string,
75+
* profile_enabledScope?: Provisioning_APIUserDetailsScope,
7476
* quota: Provisioning_APIUserDetailsQuota,
7577
* role: string,
76-
* roleScope?: string,
78+
* roleScope?: Provisioning_APIUserDetailsScope,
7779
* storageLocation?: string,
7880
* subadmin: string[],
7981
* twitter: string,
80-
* twitterScope?: string,
82+
* twitterScope?: Provisioning_APIUserDetailsScope,
8183
* website: string,
82-
* websiteScope?: string,
84+
* websiteScope?: Provisioning_APIUserDetailsScope,
8385
* }
8486
*
8587
* @psalm-type Provisioning_APIGroupDetails = array{

apps/provisioning_api/openapi-full.json

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,17 @@
162162
"additional_mailScope": {
163163
"type": "array",
164164
"items": {
165-
"type": "string"
165+
"$ref": "#/components/schemas/UserDetailsScope"
166166
}
167167
},
168168
"address": {
169169
"type": "string"
170170
},
171171
"addressScope": {
172-
"type": "string"
172+
"$ref": "#/components/schemas/UserDetailsScope"
173173
},
174174
"avatarScope": {
175-
"type": "string"
175+
"$ref": "#/components/schemas/UserDetailsScope"
176176
},
177177
"backend": {
178178
"type": "string"
@@ -196,7 +196,7 @@
196196
"type": "string"
197197
},
198198
"biographyScope": {
199-
"type": "string"
199+
"$ref": "#/components/schemas/UserDetailsScope"
200200
},
201201
"display-name": {
202202
"type": "string"
@@ -205,14 +205,14 @@
205205
"type": "string"
206206
},
207207
"displaynameScope": {
208-
"type": "string"
208+
"$ref": "#/components/schemas/UserDetailsScope"
209209
},
210210
"email": {
211211
"type": "string",
212212
"nullable": true
213213
},
214214
"emailScope": {
215-
"type": "string"
215+
"$ref": "#/components/schemas/UserDetailsScope"
216216
},
217217
"enabled": {
218218
"type": "boolean"
@@ -221,7 +221,7 @@
221221
"type": "string"
222222
},
223223
"fediverseScope": {
224-
"type": "string"
224+
"$ref": "#/components/schemas/UserDetailsScope"
225225
},
226226
"groups": {
227227
"type": "array",
@@ -233,7 +233,7 @@
233233
"type": "string"
234234
},
235235
"headlineScope": {
236-
"type": "string"
236+
"$ref": "#/components/schemas/UserDetailsScope"
237237
},
238238
"id": {
239239
"type": "string"
@@ -259,19 +259,19 @@
259259
"type": "string"
260260
},
261261
"organisationScope": {
262-
"type": "string"
262+
"$ref": "#/components/schemas/UserDetailsScope"
263263
},
264264
"phone": {
265265
"type": "string"
266266
},
267267
"phoneScope": {
268-
"type": "string"
268+
"$ref": "#/components/schemas/UserDetailsScope"
269269
},
270270
"profile_enabled": {
271271
"type": "string"
272272
},
273273
"profile_enabledScope": {
274-
"type": "string"
274+
"$ref": "#/components/schemas/UserDetailsScope"
275275
},
276276
"quota": {
277277
"$ref": "#/components/schemas/UserDetailsQuota"
@@ -280,7 +280,7 @@
280280
"type": "string"
281281
},
282282
"roleScope": {
283-
"type": "string"
283+
"$ref": "#/components/schemas/UserDetailsScope"
284284
},
285285
"storageLocation": {
286286
"type": "string"
@@ -295,13 +295,13 @@
295295
"type": "string"
296296
},
297297
"twitterScope": {
298-
"type": "string"
298+
"$ref": "#/components/schemas/UserDetailsScope"
299299
},
300300
"website": {
301301
"type": "string"
302302
},
303303
"websiteScope": {
304-
"type": "string"
304+
"$ref": "#/components/schemas/UserDetailsScope"
305305
}
306306
}
307307
},
@@ -372,6 +372,18 @@
372372
]
373373
}
374374
}
375+
},
376+
"UserDetailsScope": {
377+
"type": "string",
378+
"enum": [
379+
"v2-private",
380+
"v2-local",
381+
"v2-federated",
382+
"v2-published",
383+
"private",
384+
"contacts",
385+
"public"
386+
]
375387
}
376388
}
377389
},

apps/provisioning_api/openapi.json

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,17 @@
162162
"additional_mailScope": {
163163
"type": "array",
164164
"items": {
165-
"type": "string"
165+
"$ref": "#/components/schemas/UserDetailsScope"
166166
}
167167
},
168168
"address": {
169169
"type": "string"
170170
},
171171
"addressScope": {
172-
"type": "string"
172+
"$ref": "#/components/schemas/UserDetailsScope"
173173
},
174174
"avatarScope": {
175-
"type": "string"
175+
"$ref": "#/components/schemas/UserDetailsScope"
176176
},
177177
"backend": {
178178
"type": "string"
@@ -196,7 +196,7 @@
196196
"type": "string"
197197
},
198198
"biographyScope": {
199-
"type": "string"
199+
"$ref": "#/components/schemas/UserDetailsScope"
200200
},
201201
"display-name": {
202202
"type": "string"
@@ -205,14 +205,14 @@
205205
"type": "string"
206206
},
207207
"displaynameScope": {
208-
"type": "string"
208+
"$ref": "#/components/schemas/UserDetailsScope"
209209
},
210210
"email": {
211211
"type": "string",
212212
"nullable": true
213213
},
214214
"emailScope": {
215-
"type": "string"
215+
"$ref": "#/components/schemas/UserDetailsScope"
216216
},
217217
"enabled": {
218218
"type": "boolean"
@@ -221,7 +221,7 @@
221221
"type": "string"
222222
},
223223
"fediverseScope": {
224-
"type": "string"
224+
"$ref": "#/components/schemas/UserDetailsScope"
225225
},
226226
"groups": {
227227
"type": "array",
@@ -233,7 +233,7 @@
233233
"type": "string"
234234
},
235235
"headlineScope": {
236-
"type": "string"
236+
"$ref": "#/components/schemas/UserDetailsScope"
237237
},
238238
"id": {
239239
"type": "string"
@@ -259,19 +259,19 @@
259259
"type": "string"
260260
},
261261
"organisationScope": {
262-
"type": "string"
262+
"$ref": "#/components/schemas/UserDetailsScope"
263263
},
264264
"phone": {
265265
"type": "string"
266266
},
267267
"phoneScope": {
268-
"type": "string"
268+
"$ref": "#/components/schemas/UserDetailsScope"
269269
},
270270
"profile_enabled": {
271271
"type": "string"
272272
},
273273
"profile_enabledScope": {
274-
"type": "string"
274+
"$ref": "#/components/schemas/UserDetailsScope"
275275
},
276276
"quota": {
277277
"$ref": "#/components/schemas/UserDetailsQuota"
@@ -280,7 +280,7 @@
280280
"type": "string"
281281
},
282282
"roleScope": {
283-
"type": "string"
283+
"$ref": "#/components/schemas/UserDetailsScope"
284284
},
285285
"storageLocation": {
286286
"type": "string"
@@ -295,13 +295,13 @@
295295
"type": "string"
296296
},
297297
"twitterScope": {
298-
"type": "string"
298+
"$ref": "#/components/schemas/UserDetailsScope"
299299
},
300300
"website": {
301301
"type": "string"
302302
},
303303
"websiteScope": {
304-
"type": "string"
304+
"$ref": "#/components/schemas/UserDetailsScope"
305305
}
306306
}
307307
},
@@ -372,6 +372,18 @@
372372
]
373373
}
374374
}
375+
},
376+
"UserDetailsScope": {
377+
"type": "string",
378+
"enum": [
379+
"v2-private",
380+
"v2-local",
381+
"v2-federated",
382+
"v2-published",
383+
"private",
384+
"contacts",
385+
"public"
386+
]
375387
}
376388
}
377389
},

lib/private/Accounts/AccountProperty.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
use OCP\Accounts\IAccountProperty;
3333

3434
class AccountProperty implements IAccountProperty {
35+
/**
36+
* @var IAccountManager::SCOPE_*
37+
*/
3538
private string $scope;
3639
private string $locallyVerified = IAccountManager::NOT_VERIFIED;
3740

lib/public/Accounts/IAccountProperty.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public function setValue(string $value): IAccountProperty;
5050
* @since 15.0.0
5151
*
5252
* @param string $scope
53+
* @psalm-param IAccountManager::SCOPE_* $scope
5354
* @return IAccountProperty
5455
* @throws InvalidArgumentException (since 22.0.0)
5556
*/
@@ -89,6 +90,7 @@ public function getValue(): string;
8990
* @since 15.0.0
9091
*
9192
* @return string
93+
* @psalm-return IAccountManager::SCOPE_*
9294
*/
9395
public function getScope(): string;
9496

0 commit comments

Comments
 (0)