Skip to content

Commit

Permalink
refactor(provisioning_api): Add types for user details scopes
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <kate@provokateurin.de>
  • Loading branch information
provokateurin committed May 11, 2024
1 parent 4dc73b3 commit aff7798
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 42 deletions.
30 changes: 16 additions & 14 deletions apps/provisioning_api/lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,51 +35,53 @@
* used?: float|int,
* }
*
* @psalm-type Provisioning_APIUserDetailsScope = 'v2-private'|'v2-local'|'v2-federated'|'v2-published'|'private'|'contacts'|'public'
*
* @psalm-type Provisioning_APIUserDetails = array{
* additional_mail: string[],
* additional_mailScope?: string[],
* additional_mailScope?: Provisioning_APIUserDetailsScope[],
* address: string,
* addressScope?: string,
* avatarScope?: string,
* addressScope?: Provisioning_APIUserDetailsScope,
* avatarScope?: Provisioning_APIUserDetailsScope,
* backend: string,
* backendCapabilities: array{
* setDisplayName: bool,
* setPassword: bool
* },
* biography: string,
* biographyScope?: string,
* biographyScope?: Provisioning_APIUserDetailsScope,
* display-name: string,
* displayname: string,
* displaynameScope?: string,
* displaynameScope?: Provisioning_APIUserDetailsScope,
* email: ?string,
* emailScope?: string,
* emailScope?: Provisioning_APIUserDetailsScope,
* enabled?: bool,
* fediverse: string,
* fediverseScope?: string,
* fediverseScope?: Provisioning_APIUserDetailsScope,
* groups: string[],
* headline: string,
* headlineScope?: string,
* headlineScope?: Provisioning_APIUserDetailsScope,
* id: string,
* language: string,
* lastLogin: int,
* locale: string,
* manager: string,
* notify_email: ?string,
* organisation: string,
* organisationScope?: string,
* organisationScope?: Provisioning_APIUserDetailsScope,
* phone: string,
* phoneScope?: string,
* phoneScope?: Provisioning_APIUserDetailsScope,
* profile_enabled: string,
* profile_enabledScope?: string,
* profile_enabledScope?: Provisioning_APIUserDetailsScope,
* quota: Provisioning_APIUserDetailsQuota,
* role: string,
* roleScope?: string,
* roleScope?: Provisioning_APIUserDetailsScope,
* storageLocation?: string,
* subadmin: string[],
* twitter: string,
* twitterScope?: string,
* twitterScope?: Provisioning_APIUserDetailsScope,
* website: string,
* websiteScope?: string,
* websiteScope?: Provisioning_APIUserDetailsScope,
* }
*
* @psalm-type Provisioning_APIGroupDetails = array{
Expand Down
40 changes: 26 additions & 14 deletions apps/provisioning_api/openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,17 @@
"additional_mailScope": {
"type": "array",
"items": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
}
},
"address": {
"type": "string"
},
"addressScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"avatarScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"backend": {
"type": "string"
Expand All @@ -196,7 +196,7 @@
"type": "string"
},
"biographyScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"display-name": {
"type": "string"
Expand All @@ -205,14 +205,14 @@
"type": "string"
},
"displaynameScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"email": {
"type": "string",
"nullable": true
},
"emailScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"enabled": {
"type": "boolean"
Expand All @@ -221,7 +221,7 @@
"type": "string"
},
"fediverseScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"groups": {
"type": "array",
Expand All @@ -233,7 +233,7 @@
"type": "string"
},
"headlineScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"id": {
"type": "string"
Expand All @@ -259,19 +259,19 @@
"type": "string"
},
"organisationScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"phone": {
"type": "string"
},
"phoneScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"profile_enabled": {
"type": "string"
},
"profile_enabledScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"quota": {
"$ref": "#/components/schemas/UserDetailsQuota"
Expand All @@ -280,7 +280,7 @@
"type": "string"
},
"roleScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"storageLocation": {
"type": "string"
Expand All @@ -295,13 +295,13 @@
"type": "string"
},
"twitterScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"website": {
"type": "string"
},
"websiteScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
}
}
},
Expand Down Expand Up @@ -372,6 +372,18 @@
]
}
}
},
"UserDetailsScope": {
"type": "string",
"enum": [
"v2-private",
"v2-local",
"v2-federated",
"v2-published",
"private",
"contacts",
"public"
]
}
}
},
Expand Down
40 changes: 26 additions & 14 deletions apps/provisioning_api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,17 @@
"additional_mailScope": {
"type": "array",
"items": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
}
},
"address": {
"type": "string"
},
"addressScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"avatarScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"backend": {
"type": "string"
Expand All @@ -196,7 +196,7 @@
"type": "string"
},
"biographyScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"display-name": {
"type": "string"
Expand All @@ -205,14 +205,14 @@
"type": "string"
},
"displaynameScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"email": {
"type": "string",
"nullable": true
},
"emailScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"enabled": {
"type": "boolean"
Expand All @@ -221,7 +221,7 @@
"type": "string"
},
"fediverseScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"groups": {
"type": "array",
Expand All @@ -233,7 +233,7 @@
"type": "string"
},
"headlineScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"id": {
"type": "string"
Expand All @@ -259,19 +259,19 @@
"type": "string"
},
"organisationScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"phone": {
"type": "string"
},
"phoneScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"profile_enabled": {
"type": "string"
},
"profile_enabledScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"quota": {
"$ref": "#/components/schemas/UserDetailsQuota"
Expand All @@ -280,7 +280,7 @@
"type": "string"
},
"roleScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"storageLocation": {
"type": "string"
Expand All @@ -295,13 +295,13 @@
"type": "string"
},
"twitterScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
},
"website": {
"type": "string"
},
"websiteScope": {
"type": "string"
"$ref": "#/components/schemas/UserDetailsScope"
}
}
},
Expand Down Expand Up @@ -372,6 +372,18 @@
]
}
}
},
"UserDetailsScope": {
"type": "string",
"enum": [
"v2-private",
"v2-local",
"v2-federated",
"v2-published",
"private",
"contacts",
"public"
]
}
}
},
Expand Down
3 changes: 3 additions & 0 deletions lib/private/Accounts/AccountProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
use OCP\Accounts\IAccountProperty;

class AccountProperty implements IAccountProperty {
/**
* @var IAccountManager::SCOPE_*
*/
private string $scope;
private string $locallyVerified = IAccountManager::NOT_VERIFIED;

Expand Down
2 changes: 2 additions & 0 deletions lib/public/Accounts/IAccountProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function setValue(string $value): IAccountProperty;
* @since 15.0.0
*
* @param string $scope
* @psalm-param IAccountManager::SCOPE_* $scope
* @return IAccountProperty
* @throws InvalidArgumentException (since 22.0.0)
*/
Expand Down Expand Up @@ -89,6 +90,7 @@ public function getValue(): string;
* @since 15.0.0
*
* @return string
* @psalm-return IAccountManager::SCOPE_*
*/
public function getScope(): string;

Expand Down

0 comments on commit aff7798

Please sign in to comment.