Skip to content

Commit ae63945

Browse files
authored
Merge pull request #52544 from nextcloud/chore/drop-deprecated-account-scopes
2 parents b3b6302 + 1b273b8 commit ae63945

6 files changed

Lines changed: 19 additions & 90 deletions

File tree

build/integration/features/contacts-menu.feature

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,18 @@ Feature: contacts-menu
7171
And searched contact "1" is named "Test name"
7272
And searched contact "2" is named "user2"
7373

74-
75-
7674
Scenario: users can not be found by display name if visibility is private
7775
Given user "user0" exists
7876
And user "user1" exists
7977
And user "user2" exists
8078
And Logging in using web as "user1"
8179
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
8280
| displayname | Test name |
83-
| displaynameScope | private |
81+
| displaynameScope | v2-private |
8482
And Logging in using web as "user2"
8583
And Sending a "PUT" to "/settings/users/user2/settings" with requesttoken
8684
| displayname | Another test name |
87-
| displaynameScope | contacts |
85+
| displaynameScope | v2-federated |
8886
When Logging in using web as "user0"
8987
And searching for contacts matching with "test"
9088
# Disabled because it regularly fails on drone:
@@ -98,11 +96,11 @@ Feature: contacts-menu
9896
And Logging in using web as "user1"
9997
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
10098
| email | test@example.com |
101-
| emailScope | private |
99+
| emailScope | v2-private |
102100
And Logging in using web as "user2"
103101
And Sending a "PUT" to "/settings/users/user2/settings" with requesttoken
104102
| email | another_test@example.com |
105-
| emailScope | contacts |
103+
| emailScope | v2-federated |
106104
# Disabled because it regularly fails on drone:
107105
# When Logging in using web as "user0"
108106
# And searching for contacts matching with "test"
@@ -116,15 +114,15 @@ Feature: contacts-menu
116114
And Logging in using web as "user1"
117115
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
118116
| displayname | Test name |
119-
| displaynameScope | contacts |
117+
| displaynameScope | v2-federated |
120118
| email | test@example.com |
121-
| emailScope | private |
119+
| emailScope | v2-private |
122120
And Logging in using web as "user2"
123121
And Sending a "PUT" to "/settings/users/user2/settings" with requesttoken
124122
| displayname | Another test name |
125-
| displaynameScope | private |
123+
| displaynameScope | v2-private |
126124
| email | another_test@example.com |
127-
| emailScope | contacts |
125+
| emailScope | v2-federated |
128126
When Logging in using web as "user0"
129127
And searching for contacts matching with "test"
130128
Then the list of searched contacts has "2" contacts
@@ -140,9 +138,9 @@ Feature: contacts-menu
140138
And Logging in using web as "user1"
141139
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
142140
| displayname | Test name |
143-
| displaynameScope | private |
141+
| displaynameScope | v2-private |
144142
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
145-
| displaynameScope | contacts |
143+
| displaynameScope | v2-federated |
146144
When Logging in using web as "user0"
147145
And searching for contacts matching with "test"
148146
Then the list of searched contacts has "1" contacts
@@ -154,9 +152,9 @@ Feature: contacts-menu
154152
And Logging in using web as "user1"
155153
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
156154
| email | test@example.com |
157-
| emailScope | private |
155+
| emailScope | v2-private |
158156
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
159-
| emailScope | contacts |
157+
| emailScope | v2-federated |
160158
# Disabled because it regularly fails on drone:
161159
# When Logging in using web as "user0"
162160
# And searching for contacts matching with "test"
@@ -170,7 +168,7 @@ Feature: contacts-menu
170168
And user "user1" exists
171169
And Logging in using web as "user1"
172170
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
173-
| displaynameScope | private |
171+
| displaynameScope | v2-private |
174172
And As an "admin"
175173
And sending "PUT" to "/cloud/users/user1" with
176174
| key | displayname |
@@ -185,7 +183,7 @@ Feature: contacts-menu
185183
And user "user1" exists
186184
And Logging in using web as "user1"
187185
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
188-
| emailScope | private |
186+
| emailScope | v2-private |
189187
And As an "admin"
190188
And sending "PUT" to "/cloud/users/user1" with
191189
| key | email |

build/integration/features/provisioning-v1.feature

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -210,21 +210,6 @@ Feature: provisioning
210210
| value | v2-published |
211211
Then the OCS status code should be "100"
212212
And the HTTP status code should be "200"
213-
When sending "PUT" to "/cloud/users/brand-new-user" with
214-
| key | websiteScope |
215-
| value | public |
216-
Then the OCS status code should be "100"
217-
And the HTTP status code should be "200"
218-
When sending "PUT" to "/cloud/users/brand-new-user" with
219-
| key | displaynameScope |
220-
| value | contacts |
221-
Then the OCS status code should be "100"
222-
And the HTTP status code should be "200"
223-
When sending "PUT" to "/cloud/users/brand-new-user" with
224-
| key | avatarScope |
225-
| value | private |
226-
Then the OCS status code should be "100"
227-
And the HTTP status code should be "200"
228213
And sending "PUT" to "/cloud/users/brand-new-user" with
229214
| key | email |
230215
| value | no-reply@nextcloud.com |
@@ -253,9 +238,6 @@ Feature: provisioning
253238
| twitterScope | v2-local |
254239
| addressScope | v2-federated |
255240
| emailScope | v2-published |
256-
| websiteScope | v2-published |
257-
| displaynameScope | v2-federated |
258-
| avatarScope | v2-local |
259241

260242
Scenario: Edit a user account multivalue property scopes
261243
Given user "brand-new-user" exists

lib/private/Accounts/AccountManager.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ protected function testPropertyScope(IAccountProperty $property, array $allowedS
131131
$property->setScope(self::SCOPE_LOCAL);
132132
}
133133
} else {
134-
// migrate scope values to the new format
135-
// invalid scopes are mapped to a default value
136-
$property->setScope(AccountProperty::mapScopeToV2($property->getScope()));
134+
$property->setScope($property->getScope());
137135
}
138136
}
139137

lib/private/Accounts/AccountProperty.php

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,11 @@ public function setValue(string $value): IAccountProperty {
5555
* @since 15.0.0
5656
*/
5757
public function setScope(string $scope): IAccountProperty {
58-
$newScope = $this->mapScopeToV2($scope);
59-
if (!in_array($newScope, [
60-
IAccountManager::SCOPE_LOCAL,
61-
IAccountManager::SCOPE_FEDERATED,
62-
IAccountManager::SCOPE_PRIVATE,
63-
IAccountManager::SCOPE_PUBLISHED
64-
])) {
58+
if (!in_array($scope, IAccountManager::ALLOWED_SCOPES, )) {
6559
throw new InvalidArgumentException('Invalid scope');
6660
}
67-
$this->scope = $newScope;
61+
/** @var IAccountManager::SCOPE_* $scope */
62+
$this->scope = $scope;
6863
return $this;
6964
}
7065

@@ -105,19 +100,6 @@ public function getScope(): string {
105100
return $this->scope;
106101
}
107102

108-
public static function mapScopeToV2(string $scope): string {
109-
if (str_starts_with($scope, 'v2-')) {
110-
return $scope;
111-
}
112-
113-
return match ($scope) {
114-
IAccountManager::VISIBILITY_PRIVATE, '' => IAccountManager::SCOPE_LOCAL,
115-
IAccountManager::VISIBILITY_CONTACTS_ONLY => IAccountManager::SCOPE_FEDERATED,
116-
IAccountManager::VISIBILITY_PUBLIC => IAccountManager::SCOPE_PUBLISHED,
117-
default => $scope,
118-
};
119-
}
120-
121103
/**
122104
* Get the verification status of a property
123105
*

lib/public/Accounts/IAccountManager.php

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,30 +47,6 @@ interface IAccountManager {
4747
*/
4848
public const SCOPE_PUBLISHED = 'v2-published';
4949

50-
/**
51-
* Contact details only visible locally
52-
*
53-
* @since 15.0.0
54-
* @deprecated 21.0.1
55-
*/
56-
public const VISIBILITY_PRIVATE = 'private';
57-
58-
/**
59-
* Contact details visible on trusted federated servers.
60-
*
61-
* @since 15.0.0
62-
* @deprecated 21.0.1
63-
*/
64-
public const VISIBILITY_CONTACTS_ONLY = 'contacts';
65-
66-
/**
67-
* Contact details visible on trusted federated servers and in the public lookup server.
68-
*
69-
* @since 15.0.0
70-
* @deprecated 21.0.1
71-
*/
72-
public const VISIBILITY_PUBLIC = 'public';
73-
7450
/**
7551
* The list of allowed scopes
7652
*
@@ -81,9 +57,6 @@ interface IAccountManager {
8157
self::SCOPE_LOCAL,
8258
self::SCOPE_FEDERATED,
8359
self::SCOPE_PUBLISHED,
84-
self::VISIBILITY_PRIVATE,
85-
self::VISIBILITY_CONTACTS_ONLY,
86-
self::VISIBILITY_PUBLIC,
8760
];
8861

8962
/**
@@ -98,6 +71,7 @@ interface IAccountManager {
9871

9972
/**
10073
* @since 27.0.0
74+
* @deprecated 27.0.0 only added for backwards compatibility with provisioning_api UsersController::getCurrentUser
10175
*/
10276
public const PROPERTY_DISPLAYNAME_LEGACY = 'display-name';
10377

tests/lib/Accounts/AccountPropertyTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ public function scopesProvider() {
6363
[IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_LOCAL],
6464
[IAccountManager::SCOPE_FEDERATED, IAccountManager::SCOPE_FEDERATED],
6565
[IAccountManager::SCOPE_PUBLISHED, IAccountManager::SCOPE_PUBLISHED],
66-
// legacy values
67-
[IAccountManager::VISIBILITY_PRIVATE, IAccountManager::SCOPE_LOCAL],
68-
[IAccountManager::VISIBILITY_CONTACTS_ONLY, IAccountManager::SCOPE_FEDERATED],
69-
[IAccountManager::VISIBILITY_PUBLIC, IAccountManager::SCOPE_PUBLISHED],
70-
['', IAccountManager::SCOPE_LOCAL],
7166
// invalid values
7267
['unknown', null],
7368
['v2-unknown', null],

0 commit comments

Comments
 (0)