chore(IAccountManager): remove deprecated visibility constants

Those constants are not used anywhere anymore and are deprecated for
more than ten versions. So its time to cleanup the interface.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/52544/head
Ferdinand Thiessen 2025-04-29 19:33:38 +07:00
parent 14f79829f3
commit 1b273b8c2c
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
6 changed files with 19 additions and 90 deletions

@ -71,8 +71,6 @@ Feature: contacts-menu
And searched contact "1" is named "Test name" And searched contact "1" is named "Test name"
And searched contact "2" is named "user2" And searched contact "2" is named "user2"
Scenario: users can not be found by display name if visibility is private Scenario: users can not be found by display name if visibility is private
Given user "user0" exists Given user "user0" exists
And user "user1" exists And user "user1" exists
@ -80,11 +78,11 @@ Feature: contacts-menu
And Logging in using web as "user1" And Logging in using web as "user1"
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
| displayname | Test name | | displayname | Test name |
| displaynameScope | private | | displaynameScope | v2-private |
And Logging in using web as "user2" And Logging in using web as "user2"
And Sending a "PUT" to "/settings/users/user2/settings" with requesttoken And Sending a "PUT" to "/settings/users/user2/settings" with requesttoken
| displayname | Another test name | | displayname | Another test name |
| displaynameScope | contacts | | displaynameScope | v2-federated |
When Logging in using web as "user0" When Logging in using web as "user0"
And searching for contacts matching with "test" And searching for contacts matching with "test"
# Disabled because it regularly fails on drone: # Disabled because it regularly fails on drone:
@ -98,11 +96,11 @@ Feature: contacts-menu
And Logging in using web as "user1" And Logging in using web as "user1"
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
| email | test@example.com | | email | test@example.com |
| emailScope | private | | emailScope | v2-private |
And Logging in using web as "user2" And Logging in using web as "user2"
And Sending a "PUT" to "/settings/users/user2/settings" with requesttoken And Sending a "PUT" to "/settings/users/user2/settings" with requesttoken
| email | another_test@example.com | | email | another_test@example.com |
| emailScope | contacts | | emailScope | v2-federated |
# Disabled because it regularly fails on drone: # Disabled because it regularly fails on drone:
# When Logging in using web as "user0" # When Logging in using web as "user0"
# And searching for contacts matching with "test" # And searching for contacts matching with "test"
@ -116,15 +114,15 @@ Feature: contacts-menu
And Logging in using web as "user1" And Logging in using web as "user1"
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
| displayname | Test name | | displayname | Test name |
| displaynameScope | contacts | | displaynameScope | v2-federated |
| email | test@example.com | | email | test@example.com |
| emailScope | private | | emailScope | v2-private |
And Logging in using web as "user2" And Logging in using web as "user2"
And Sending a "PUT" to "/settings/users/user2/settings" with requesttoken And Sending a "PUT" to "/settings/users/user2/settings" with requesttoken
| displayname | Another test name | | displayname | Another test name |
| displaynameScope | private | | displaynameScope | v2-private |
| email | another_test@example.com | | email | another_test@example.com |
| emailScope | contacts | | emailScope | v2-federated |
When Logging in using web as "user0" When Logging in using web as "user0"
And searching for contacts matching with "test" And searching for contacts matching with "test"
Then the list of searched contacts has "2" contacts Then the list of searched contacts has "2" contacts
@ -140,9 +138,9 @@ Feature: contacts-menu
And Logging in using web as "user1" And Logging in using web as "user1"
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
| displayname | Test name | | displayname | Test name |
| displaynameScope | private | | displaynameScope | v2-private |
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
| displaynameScope | contacts | | displaynameScope | v2-federated |
When Logging in using web as "user0" When Logging in using web as "user0"
And searching for contacts matching with "test" And searching for contacts matching with "test"
Then the list of searched contacts has "1" contacts Then the list of searched contacts has "1" contacts
@ -154,9 +152,9 @@ Feature: contacts-menu
And Logging in using web as "user1" And Logging in using web as "user1"
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
| email | test@example.com | | email | test@example.com |
| emailScope | private | | emailScope | v2-private |
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
| emailScope | contacts | | emailScope | v2-federated |
# Disabled because it regularly fails on drone: # Disabled because it regularly fails on drone:
# When Logging in using web as "user0" # When Logging in using web as "user0"
# And searching for contacts matching with "test" # And searching for contacts matching with "test"
@ -170,7 +168,7 @@ Feature: contacts-menu
And user "user1" exists And user "user1" exists
And Logging in using web as "user1" And Logging in using web as "user1"
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
| displaynameScope | private | | displaynameScope | v2-private |
And As an "admin" And As an "admin"
And sending "PUT" to "/cloud/users/user1" with And sending "PUT" to "/cloud/users/user1" with
| key | displayname | | key | displayname |
@ -185,7 +183,7 @@ Feature: contacts-menu
And user "user1" exists And user "user1" exists
And Logging in using web as "user1" And Logging in using web as "user1"
And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken And Sending a "PUT" to "/settings/users/user1/settings" with requesttoken
| emailScope | private | | emailScope | v2-private |
And As an "admin" And As an "admin"
And sending "PUT" to "/cloud/users/user1" with And sending "PUT" to "/cloud/users/user1" with
| key | email | | key | email |

@ -210,21 +210,6 @@ Feature: provisioning
| value | v2-published | | value | v2-published |
Then the OCS status code should be "100" Then the OCS status code should be "100"
And the HTTP status code should be "200" And the HTTP status code should be "200"
When sending "PUT" to "/cloud/users/brand-new-user" with
| key | websiteScope |
| value | public |
Then the OCS status code should be "100"
And the HTTP status code should be "200"
When sending "PUT" to "/cloud/users/brand-new-user" with
| key | displaynameScope |
| value | contacts |
Then the OCS status code should be "100"
And the HTTP status code should be "200"
When sending "PUT" to "/cloud/users/brand-new-user" with
| key | avatarScope |
| value | private |
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And sending "PUT" to "/cloud/users/brand-new-user" with And sending "PUT" to "/cloud/users/brand-new-user" with
| key | email | | key | email |
| value | no-reply@nextcloud.com | | value | no-reply@nextcloud.com |
@ -253,9 +238,6 @@ Feature: provisioning
| twitterScope | v2-local | | twitterScope | v2-local |
| addressScope | v2-federated | | addressScope | v2-federated |
| emailScope | v2-published | | emailScope | v2-published |
| websiteScope | v2-published |
| displaynameScope | v2-federated |
| avatarScope | v2-local |
Scenario: Edit a user account multivalue property scopes Scenario: Edit a user account multivalue property scopes
Given user "brand-new-user" exists Given user "brand-new-user" exists

@ -131,9 +131,7 @@ class AccountManager implements IAccountManager {
$property->setScope(self::SCOPE_LOCAL); $property->setScope(self::SCOPE_LOCAL);
} }
} else { } else {
// migrate scope values to the new format $property->setScope($property->getScope());
// invalid scopes are mapped to a default value
$property->setScope(AccountProperty::mapScopeToV2($property->getScope()));
} }
} }

@ -55,16 +55,11 @@ class AccountProperty implements IAccountProperty {
* @since 15.0.0 * @since 15.0.0
*/ */
public function setScope(string $scope): IAccountProperty { public function setScope(string $scope): IAccountProperty {
$newScope = $this->mapScopeToV2($scope); if (!in_array($scope, IAccountManager::ALLOWED_SCOPES, )) {
if (!in_array($newScope, [
IAccountManager::SCOPE_LOCAL,
IAccountManager::SCOPE_FEDERATED,
IAccountManager::SCOPE_PRIVATE,
IAccountManager::SCOPE_PUBLISHED
])) {
throw new InvalidArgumentException('Invalid scope'); throw new InvalidArgumentException('Invalid scope');
} }
$this->scope = $newScope; /** @var IAccountManager::SCOPE_* $scope */
$this->scope = $scope;
return $this; return $this;
} }
@ -105,19 +100,6 @@ class AccountProperty implements IAccountProperty {
return $this->scope; return $this->scope;
} }
public static function mapScopeToV2(string $scope): string {
if (str_starts_with($scope, 'v2-')) {
return $scope;
}
return match ($scope) {
IAccountManager::VISIBILITY_PRIVATE, '' => IAccountManager::SCOPE_LOCAL,
IAccountManager::VISIBILITY_CONTACTS_ONLY => IAccountManager::SCOPE_FEDERATED,
IAccountManager::VISIBILITY_PUBLIC => IAccountManager::SCOPE_PUBLISHED,
default => $scope,
};
}
/** /**
* Get the verification status of a property * Get the verification status of a property
* *

@ -47,30 +47,6 @@ interface IAccountManager {
*/ */
public const SCOPE_PUBLISHED = 'v2-published'; public const SCOPE_PUBLISHED = 'v2-published';
/**
* Contact details only visible locally
*
* @since 15.0.0
* @deprecated 21.0.1
*/
public const VISIBILITY_PRIVATE = 'private';
/**
* Contact details visible on trusted federated servers.
*
* @since 15.0.0
* @deprecated 21.0.1
*/
public const VISIBILITY_CONTACTS_ONLY = 'contacts';
/**
* Contact details visible on trusted federated servers and in the public lookup server.
*
* @since 15.0.0
* @deprecated 21.0.1
*/
public const VISIBILITY_PUBLIC = 'public';
/** /**
* The list of allowed scopes * The list of allowed scopes
* *
@ -81,9 +57,6 @@ interface IAccountManager {
self::SCOPE_LOCAL, self::SCOPE_LOCAL,
self::SCOPE_FEDERATED, self::SCOPE_FEDERATED,
self::SCOPE_PUBLISHED, self::SCOPE_PUBLISHED,
self::VISIBILITY_PRIVATE,
self::VISIBILITY_CONTACTS_ONLY,
self::VISIBILITY_PUBLIC,
]; ];
/** /**
@ -98,6 +71,7 @@ interface IAccountManager {
/** /**
* @since 27.0.0 * @since 27.0.0
* @deprecated 27.0.0 only added for backwards compatibility with provisioning_api UsersController::getCurrentUser
*/ */
public const PROPERTY_DISPLAYNAME_LEGACY = 'display-name'; public const PROPERTY_DISPLAYNAME_LEGACY = 'display-name';

@ -63,11 +63,6 @@ class AccountPropertyTest extends TestCase {
[IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_LOCAL], [IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_LOCAL],
[IAccountManager::SCOPE_FEDERATED, IAccountManager::SCOPE_FEDERATED], [IAccountManager::SCOPE_FEDERATED, IAccountManager::SCOPE_FEDERATED],
[IAccountManager::SCOPE_PUBLISHED, IAccountManager::SCOPE_PUBLISHED], [IAccountManager::SCOPE_PUBLISHED, IAccountManager::SCOPE_PUBLISHED],
// legacy values
[IAccountManager::VISIBILITY_PRIVATE, IAccountManager::SCOPE_LOCAL],
[IAccountManager::VISIBILITY_CONTACTS_ONLY, IAccountManager::SCOPE_FEDERATED],
[IAccountManager::VISIBILITY_PUBLIC, IAccountManager::SCOPE_PUBLISHED],
['', IAccountManager::SCOPE_LOCAL],
// invalid values // invalid values
['unknown', null], ['unknown', null],
['v2-unknown', null], ['v2-unknown', null],