Map old account scope properties to new names
Use new scope values in settings page. Adjust all consumers to use the new constants. Map old scope values to new ones in account property getter. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
This commit is contained in:
parent
e2ab530ee3
commit
5d76574a81
|
@ -71,8 +71,8 @@ class Converter {
|
||||||
|
|
||||||
foreach ($userData as $property => $value) {
|
foreach ($userData as $property => $value) {
|
||||||
$shareWithTrustedServers =
|
$shareWithTrustedServers =
|
||||||
$value['scope'] === AccountManager::VISIBILITY_CONTACTS_ONLY ||
|
$value['scope'] === AccountManager::SCOPE_FEDERATED ||
|
||||||
$value['scope'] === AccountManager::VISIBILITY_PUBLIC;
|
$value['scope'] === AccountManager::SCOPE_PUBLISHED;
|
||||||
|
|
||||||
$emptyValue = !isset($value['value']) || $value['value'] === '';
|
$emptyValue = !isset($value['value']) || $value['value'] === '';
|
||||||
|
|
||||||
|
|
|
@ -53,36 +53,36 @@ class ConverterTest extends TestCase {
|
||||||
IAccountManager::PROPERTY_DISPLAYNAME =>
|
IAccountManager::PROPERTY_DISPLAYNAME =>
|
||||||
[
|
[
|
||||||
'value' => $user->getDisplayName(),
|
'value' => $user->getDisplayName(),
|
||||||
'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY,
|
'scope' => AccountManager::SCOPE_FEDERATED,
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_ADDRESS =>
|
IAccountManager::PROPERTY_ADDRESS =>
|
||||||
[
|
[
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'scope' => AccountManager::VISIBILITY_PRIVATE,
|
'scope' => AccountManager::SCOPE_LOCAL,
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_WEBSITE =>
|
IAccountManager::PROPERTY_WEBSITE =>
|
||||||
[
|
[
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'scope' => AccountManager::VISIBILITY_PRIVATE,
|
'scope' => AccountManager::SCOPE_LOCAL,
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_EMAIL =>
|
IAccountManager::PROPERTY_EMAIL =>
|
||||||
[
|
[
|
||||||
'value' => $user->getEMailAddress(),
|
'value' => $user->getEMailAddress(),
|
||||||
'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY,
|
'scope' => AccountManager::SCOPE_FEDERATED,
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_AVATAR =>
|
IAccountManager::PROPERTY_AVATAR =>
|
||||||
[
|
[
|
||||||
'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY
|
'scope' => AccountManager::SCOPE_FEDERATED
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_PHONE =>
|
IAccountManager::PROPERTY_PHONE =>
|
||||||
[
|
[
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'scope' => AccountManager::VISIBILITY_PRIVATE,
|
'scope' => AccountManager::SCOPE_LOCAL,
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_TWITTER =>
|
IAccountManager::PROPERTY_TWITTER =>
|
||||||
[
|
[
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'scope' => AccountManager::VISIBILITY_PRIVATE,
|
'scope' => AccountManager::SCOPE_LOCAL,
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -136,36 +136,36 @@ class SyncServiceTest extends TestCase {
|
||||||
IAccountManager::PROPERTY_DISPLAYNAME =>
|
IAccountManager::PROPERTY_DISPLAYNAME =>
|
||||||
[
|
[
|
||||||
'value' => $user->getDisplayName(),
|
'value' => $user->getDisplayName(),
|
||||||
'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY,
|
'scope' => AccountManager::SCOPE_FEDERATED,
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_ADDRESS =>
|
IAccountManager::PROPERTY_ADDRESS =>
|
||||||
[
|
[
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'scope' => AccountManager::VISIBILITY_PRIVATE,
|
'scope' => AccountManager::SCOPE_LOCAL,
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_WEBSITE =>
|
IAccountManager::PROPERTY_WEBSITE =>
|
||||||
[
|
[
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'scope' => AccountManager::VISIBILITY_PRIVATE,
|
'scope' => AccountManager::SCOPE_LOCAL,
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_EMAIL =>
|
IAccountManager::PROPERTY_EMAIL =>
|
||||||
[
|
[
|
||||||
'value' => $user->getEMailAddress(),
|
'value' => $user->getEMailAddress(),
|
||||||
'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY,
|
'scope' => AccountManager::SCOPE_FEDERATED,
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_AVATAR =>
|
IAccountManager::PROPERTY_AVATAR =>
|
||||||
[
|
[
|
||||||
'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY
|
'scope' => AccountManager::SCOPE_FEDERATED
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_PHONE =>
|
IAccountManager::PROPERTY_PHONE =>
|
||||||
[
|
[
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'scope' => AccountManager::VISIBILITY_PRIVATE,
|
'scope' => AccountManager::SCOPE_LOCAL,
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_TWITTER =>
|
IAccountManager::PROPERTY_TWITTER =>
|
||||||
[
|
[
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'scope' => AccountManager::VISIBILITY_PRIVATE,
|
'scope' => AccountManager::SCOPE_LOCAL,
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -343,7 +343,7 @@ class ShareController extends AuthPublicShareController {
|
||||||
$ownerAccount = $this->accountManager->getAccount($owner);
|
$ownerAccount = $this->accountManager->getAccount($owner);
|
||||||
|
|
||||||
$ownerName = $ownerAccount->getProperty(IAccountManager::PROPERTY_DISPLAYNAME);
|
$ownerName = $ownerAccount->getProperty(IAccountManager::PROPERTY_DISPLAYNAME);
|
||||||
if ($ownerName->getScope() === IAccountManager::VISIBILITY_PUBLIC) {
|
if ($ownerName->getScope() === IAccountManager::SCOPE_PUBLISHED) {
|
||||||
$shareTmpl['owner'] = $owner->getUID();
|
$shareTmpl['owner'] = $owner->getUID();
|
||||||
$shareTmpl['shareOwner'] = $owner->getDisplayName();
|
$shareTmpl['shareOwner'] = $owner->getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,7 +234,7 @@ class ShareControllerTest extends \Test\TestCase {
|
||||||
|
|
||||||
$accountName = $this->createMock(IAccountProperty::class);
|
$accountName = $this->createMock(IAccountProperty::class);
|
||||||
$accountName->method('getScope')
|
$accountName->method('getScope')
|
||||||
->willReturn(IAccountManager::VISIBILITY_PUBLIC);
|
->willReturn(IAccountManager::SCOPE_PUBLISHED);
|
||||||
$account = $this->createMock(IAccount::class);
|
$account = $this->createMock(IAccount::class);
|
||||||
$account->method('getProperty')
|
$account->method('getProperty')
|
||||||
->with(IAccountManager::PROPERTY_DISPLAYNAME)
|
->with(IAccountManager::PROPERTY_DISPLAYNAME)
|
||||||
|
@ -381,7 +381,7 @@ class ShareControllerTest extends \Test\TestCase {
|
||||||
|
|
||||||
$accountName = $this->createMock(IAccountProperty::class);
|
$accountName = $this->createMock(IAccountProperty::class);
|
||||||
$accountName->method('getScope')
|
$accountName->method('getScope')
|
||||||
->willReturn(IAccountManager::VISIBILITY_PRIVATE);
|
->willReturn(IAccountManager::SCOPE_LOCAL);
|
||||||
$account = $this->createMock(IAccount::class);
|
$account = $this->createMock(IAccount::class);
|
||||||
$account->method('getProperty')
|
$account->method('getProperty')
|
||||||
->with(IAccountManager::PROPERTY_DISPLAYNAME)
|
->with(IAccountManager::PROPERTY_DISPLAYNAME)
|
||||||
|
@ -528,7 +528,7 @@ class ShareControllerTest extends \Test\TestCase {
|
||||||
|
|
||||||
$accountName = $this->createMock(IAccountProperty::class);
|
$accountName = $this->createMock(IAccountProperty::class);
|
||||||
$accountName->method('getScope')
|
$accountName->method('getScope')
|
||||||
->willReturn(IAccountManager::VISIBILITY_PUBLIC);
|
->willReturn(IAccountManager::SCOPE_PUBLISHED);
|
||||||
$account = $this->createMock(IAccount::class);
|
$account = $this->createMock(IAccount::class);
|
||||||
$account->method('getProperty')
|
$account->method('getProperty')
|
||||||
->with(IAccountManager::PROPERTY_DISPLAYNAME)
|
->with(IAccountManager::PROPERTY_DISPLAYNAME)
|
||||||
|
@ -688,7 +688,7 @@ class ShareControllerTest extends \Test\TestCase {
|
||||||
|
|
||||||
$accountName = $this->createMock(IAccountProperty::class);
|
$accountName = $this->createMock(IAccountProperty::class);
|
||||||
$accountName->method('getScope')
|
$accountName->method('getScope')
|
||||||
->willReturn(IAccountManager::VISIBILITY_PUBLIC);
|
->willReturn(IAccountManager::SCOPE_PUBLISHED);
|
||||||
$account = $this->createMock(IAccount::class);
|
$account = $this->createMock(IAccount::class);
|
||||||
$account->method('getProperty')
|
$account->method('getProperty')
|
||||||
->with(IAccountManager::PROPERTY_DISPLAYNAME)
|
->with(IAccountManager::PROPERTY_DISPLAYNAME)
|
||||||
|
|
|
@ -193,7 +193,7 @@ class RetryJob extends Job {
|
||||||
|
|
||||||
$publicData = [];
|
$publicData = [];
|
||||||
foreach ($account->getProperties() as $property) {
|
foreach ($account->getProperties() as $property) {
|
||||||
if ($property->getScope() === IAccountManager::VISIBILITY_PUBLIC) {
|
if ($property->getScope() === IAccountManager::SCOPE_PUBLISHED) {
|
||||||
$publicData[$property->getName()] = $property->getValue();
|
$publicData[$property->getName()] = $property->getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,21 +35,21 @@
|
||||||
active: false
|
active: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'private',
|
name: 'v2-local',
|
||||||
displayName: t('settings', 'Local'),
|
displayName: t('settings', 'Local'),
|
||||||
tooltip: t('settings', "Don't synchronize to servers"),
|
tooltip: t('settings', "Don't synchronize to servers"),
|
||||||
iconClass: 'icon-password',
|
iconClass: 'icon-password',
|
||||||
active: false
|
active: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'contacts',
|
name: 'v2-federated',
|
||||||
displayName: t('settings', 'Trusted'),
|
displayName: t('settings', 'Federated'),
|
||||||
tooltip: t('settings', 'Only synchronize to trusted servers'),
|
tooltip: t('settings', 'Only synchronize to trusted servers'),
|
||||||
iconClass: 'icon-contacts-dark',
|
iconClass: 'icon-contacts-dark',
|
||||||
active: false
|
active: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'public',
|
name: 'v2-published',
|
||||||
displayName: t('settings', 'Published'),
|
displayName: t('settings', 'Published'),
|
||||||
tooltip: t('settings', 'Synchronize to trusted servers and the global and public address book'),
|
tooltip: t('settings', 'Synchronize to trusted servers and the global and public address book'),
|
||||||
iconClass: 'icon-link',
|
iconClass: 'icon-link',
|
||||||
|
|
|
@ -86,8 +86,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self.showFederationScopes) {
|
if (!self.showFederationScopes) {
|
||||||
excludedScopes.push('contacts');
|
excludedScopes.push('v2-federated');
|
||||||
excludedScopes.push('public');
|
excludedScopes.push('v2-published');
|
||||||
}
|
}
|
||||||
|
|
||||||
var scopeMenu = new OC.Settings.FederationScopeMenu({
|
var scopeMenu = new OC.Settings.FederationScopeMenu({
|
||||||
|
@ -237,16 +237,16 @@
|
||||||
$icon.addClass('hidden');
|
$icon.addClass('hidden');
|
||||||
|
|
||||||
switch (scope) {
|
switch (scope) {
|
||||||
case 'private':
|
|
||||||
case 'v2-private':
|
case 'v2-private':
|
||||||
|
case 'v2-local':
|
||||||
$icon.addClass('icon-password');
|
$icon.addClass('icon-password');
|
||||||
$icon.removeClass('hidden');
|
$icon.removeClass('hidden');
|
||||||
break;
|
break;
|
||||||
case 'contacts':
|
case 'v2-federated':
|
||||||
$icon.addClass('icon-contacts-dark');
|
$icon.addClass('icon-contacts-dark');
|
||||||
$icon.removeClass('hidden');
|
$icon.removeClass('hidden');
|
||||||
break;
|
break;
|
||||||
case 'public':
|
case 'v2-published':
|
||||||
$icon.addClass('icon-link');
|
$icon.addClass('icon-link');
|
||||||
$icon.removeClass('hidden');
|
$icon.removeClass('hidden');
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace OCA\Settings\Settings\Personal;
|
||||||
|
|
||||||
use OC\Accounts\AccountManager;
|
use OC\Accounts\AccountManager;
|
||||||
use OCA\FederatedFileSharing\FederatedShareProvider;
|
use OCA\FederatedFileSharing\FederatedShareProvider;
|
||||||
|
use OCP\Accounts\IAccount;
|
||||||
use OCP\Accounts\IAccountManager;
|
use OCP\Accounts\IAccountManager;
|
||||||
use OCP\App\IAppManager;
|
use OCP\App\IAppManager;
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
|
@ -96,7 +97,7 @@ class PersonalInfo implements ISettings {
|
||||||
|
|
||||||
$uid = \OC_User::getUser();
|
$uid = \OC_User::getUser();
|
||||||
$user = $this->userManager->get($uid);
|
$user = $this->userManager->get($uid);
|
||||||
$userData = $this->accountManager->getUser($user);
|
$account = $this->accountManager->getAccount($user);
|
||||||
|
|
||||||
// make sure FS is setup before querying storage related stuff...
|
// make sure FS is setup before querying storage related stuff...
|
||||||
\OC_Util::setupFS($user->getUID());
|
\OC_Util::setupFS($user->getUID());
|
||||||
|
@ -110,7 +111,7 @@ class PersonalInfo implements ISettings {
|
||||||
|
|
||||||
$languageParameters = $this->getLanguages($user);
|
$languageParameters = $this->getLanguages($user);
|
||||||
$localeParameters = $this->getLocales($user);
|
$localeParameters = $this->getLocales($user);
|
||||||
$messageParameters = $this->getMessageParameters($userData);
|
$messageParameters = $this->getMessageParameters($account);
|
||||||
|
|
||||||
$parameters = [
|
$parameters = [
|
||||||
'total_space' => $totalSpace,
|
'total_space' => $totalSpace,
|
||||||
|
@ -119,23 +120,23 @@ class PersonalInfo implements ISettings {
|
||||||
'quota' => $storageInfo['quota'],
|
'quota' => $storageInfo['quota'],
|
||||||
'avatarChangeSupported' => $user->canChangeAvatar(),
|
'avatarChangeSupported' => $user->canChangeAvatar(),
|
||||||
'lookupServerUploadEnabled' => $lookupServerUploadEnabled,
|
'lookupServerUploadEnabled' => $lookupServerUploadEnabled,
|
||||||
'avatarScope' => $userData[IAccountManager::PROPERTY_AVATAR]['scope'],
|
'avatarScope' => $account->getProperty(IAccountManager::PROPERTY_AVATAR)->getScope(),
|
||||||
'displayNameChangeSupported' => $user->canChangeDisplayName(),
|
'displayNameChangeSupported' => $user->canChangeDisplayName(),
|
||||||
'displayName' => $userData[IAccountManager::PROPERTY_DISPLAYNAME]['value'],
|
'displayName' => $account->getProperty(IAccountManager::PROPERTY_DISPLAYNAME)->getValue(),
|
||||||
'displayNameScope' => $userData[IAccountManager::PROPERTY_DISPLAYNAME]['scope'],
|
'displayNameScope' => $account->getProperty(IAccountManager::PROPERTY_DISPLAYNAME)->getScope(),
|
||||||
'email' => $userData[IAccountManager::PROPERTY_EMAIL]['value'],
|
'email' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getValue(),
|
||||||
'emailScope' => $userData[IAccountManager::PROPERTY_EMAIL]['scope'],
|
'emailScope' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getScope(),
|
||||||
'emailVerification' => $userData[IAccountManager::PROPERTY_EMAIL]['verified'],
|
'emailVerification' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getVerified(),
|
||||||
'phone' => $userData[IAccountManager::PROPERTY_PHONE]['value'],
|
'phone' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getValue(),
|
||||||
'phoneScope' => $userData[IAccountManager::PROPERTY_PHONE]['scope'],
|
'phoneScope' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getScope(),
|
||||||
'address' => $userData[IAccountManager::PROPERTY_ADDRESS]['value'],
|
'address' => $account->getProperty(IAccountManager::PROPERTY_ADDRESS)->getValue(),
|
||||||
'addressScope' => $userData[IAccountManager::PROPERTY_ADDRESS]['scope'],
|
'addressScope' => $account->getProperty(IAccountManager::PROPERTY_ADDRESS)->getScope(),
|
||||||
'website' => $userData[IAccountManager::PROPERTY_WEBSITE]['value'],
|
'website' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getValue(),
|
||||||
'websiteScope' => $userData[IAccountManager::PROPERTY_WEBSITE]['scope'],
|
'websiteScope' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getScope(),
|
||||||
'websiteVerification' => $userData[IAccountManager::PROPERTY_WEBSITE]['verified'],
|
'websiteVerification' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getVerified(),
|
||||||
'twitter' => $userData[IAccountManager::PROPERTY_TWITTER]['value'],
|
'twitter' => $account->getProperty(IAccountManager::PROPERTY_TWITTER)->getValue(),
|
||||||
'twitterScope' => $userData[IAccountManager::PROPERTY_TWITTER]['scope'],
|
'twitterScope' => $account->getProperty(IAccountManager::PROPERTY_TWITTER)->getScope(),
|
||||||
'twitterVerification' => $userData[IAccountManager::PROPERTY_TWITTER]['verified'],
|
'twitterVerification' => $account->getProperty(IAccountManager::PROPERTY_TWITTER)->getVerified(),
|
||||||
'groups' => $this->getGroups($user),
|
'groups' => $this->getGroups($user),
|
||||||
] + $messageParameters + $languageParameters + $localeParameters;
|
] + $messageParameters + $languageParameters + $localeParameters;
|
||||||
|
|
||||||
|
@ -263,14 +264,14 @@ class PersonalInfo implements ISettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $userData
|
* @param IAccount $account
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getMessageParameters(array $userData): array {
|
private function getMessageParameters(IAccount $account): array {
|
||||||
$needVerifyMessage = [IAccountManager::PROPERTY_EMAIL, IAccountManager::PROPERTY_WEBSITE, IAccountManager::PROPERTY_TWITTER];
|
$needVerifyMessage = [IAccountManager::PROPERTY_EMAIL, IAccountManager::PROPERTY_WEBSITE, IAccountManager::PROPERTY_TWITTER];
|
||||||
$messageParameters = [];
|
$messageParameters = [];
|
||||||
foreach ($needVerifyMessage as $property) {
|
foreach ($needVerifyMessage as $property) {
|
||||||
switch ($userData[$property]['verified']) {
|
switch ($account->getProperty($property)->getVerified()) {
|
||||||
case AccountManager::VERIFIED:
|
case AccountManager::VERIFIED:
|
||||||
$message = $this->l->t('Verifying');
|
$message = $this->l->t('Verifying');
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -208,41 +208,41 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
IAccountManager::PROPERTY_DISPLAYNAME =>
|
IAccountManager::PROPERTY_DISPLAYNAME =>
|
||||||
[
|
[
|
||||||
'value' => 'Display name',
|
'value' => 'Display name',
|
||||||
'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY,
|
'scope' => AccountManager::SCOPE_FEDERATED,
|
||||||
'verified' => AccountManager::NOT_VERIFIED,
|
'verified' => AccountManager::NOT_VERIFIED,
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_ADDRESS =>
|
IAccountManager::PROPERTY_ADDRESS =>
|
||||||
[
|
[
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'scope' => AccountManager::VISIBILITY_PRIVATE,
|
'scope' => AccountManager::SCOPE_LOCAL,
|
||||||
'verified' => AccountManager::NOT_VERIFIED,
|
'verified' => AccountManager::NOT_VERIFIED,
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_WEBSITE =>
|
IAccountManager::PROPERTY_WEBSITE =>
|
||||||
[
|
[
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'scope' => AccountManager::VISIBILITY_PRIVATE,
|
'scope' => AccountManager::SCOPE_LOCAL,
|
||||||
'verified' => AccountManager::NOT_VERIFIED,
|
'verified' => AccountManager::NOT_VERIFIED,
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_EMAIL =>
|
IAccountManager::PROPERTY_EMAIL =>
|
||||||
[
|
[
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY,
|
'scope' => AccountManager::SCOPE_FEDERATED,
|
||||||
'verified' => AccountManager::NOT_VERIFIED,
|
'verified' => AccountManager::NOT_VERIFIED,
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_AVATAR =>
|
IAccountManager::PROPERTY_AVATAR =>
|
||||||
[
|
[
|
||||||
'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY
|
'scope' => AccountManager::SCOPE_FEDERATED
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_PHONE =>
|
IAccountManager::PROPERTY_PHONE =>
|
||||||
[
|
[
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'scope' => AccountManager::VISIBILITY_PRIVATE,
|
'scope' => AccountManager::SCOPE_LOCAL,
|
||||||
'verified' => AccountManager::NOT_VERIFIED,
|
'verified' => AccountManager::NOT_VERIFIED,
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_TWITTER =>
|
IAccountManager::PROPERTY_TWITTER =>
|
||||||
[
|
[
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'scope' => AccountManager::VISIBILITY_PRIVATE,
|
'scope' => AccountManager::SCOPE_LOCAL,
|
||||||
'verified' => AccountManager::NOT_VERIFIED,
|
'verified' => AccountManager::NOT_VERIFIED,
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
@ -255,19 +255,19 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $controller->setUserSettings(//
|
$result = $controller->setUserSettings(//
|
||||||
AccountManager::VISIBILITY_CONTACTS_ONLY,
|
AccountManager::SCOPE_FEDERATED,
|
||||||
'displayName',
|
'displayName',
|
||||||
AccountManager::VISIBILITY_CONTACTS_ONLY,
|
AccountManager::SCOPE_FEDERATED,
|
||||||
'47658468',
|
'47658468',
|
||||||
AccountManager::VISIBILITY_CONTACTS_ONLY,
|
AccountManager::SCOPE_FEDERATED,
|
||||||
$email,
|
$email,
|
||||||
AccountManager::VISIBILITY_CONTACTS_ONLY,
|
AccountManager::SCOPE_FEDERATED,
|
||||||
'nextcloud.com',
|
'nextcloud.com',
|
||||||
AccountManager::VISIBILITY_CONTACTS_ONLY,
|
AccountManager::SCOPE_FEDERATED,
|
||||||
'street and city',
|
'street and city',
|
||||||
AccountManager::VISIBILITY_CONTACTS_ONLY,
|
AccountManager::SCOPE_FEDERATED,
|
||||||
'@nextclouders',
|
'@nextclouders',
|
||||||
AccountManager::VISIBILITY_CONTACTS_ONLY
|
AccountManager::SCOPE_FEDERATED
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertSame($expectedStatus, $result->getStatus());
|
$this->assertSame($expectedStatus, $result->getStatus());
|
||||||
|
|
|
@ -421,41 +421,41 @@ class AccountManager implements IAccountManager {
|
||||||
self::PROPERTY_DISPLAYNAME =>
|
self::PROPERTY_DISPLAYNAME =>
|
||||||
[
|
[
|
||||||
'value' => $user->getDisplayName(),
|
'value' => $user->getDisplayName(),
|
||||||
'scope' => self::VISIBILITY_CONTACTS_ONLY,
|
'scope' => self::SCOPE_FEDERATED,
|
||||||
'verified' => self::NOT_VERIFIED,
|
'verified' => self::NOT_VERIFIED,
|
||||||
],
|
],
|
||||||
self::PROPERTY_ADDRESS =>
|
self::PROPERTY_ADDRESS =>
|
||||||
[
|
[
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'scope' => self::VISIBILITY_PRIVATE,
|
'scope' => self::SCOPE_LOCAL,
|
||||||
'verified' => self::NOT_VERIFIED,
|
'verified' => self::NOT_VERIFIED,
|
||||||
],
|
],
|
||||||
self::PROPERTY_WEBSITE =>
|
self::PROPERTY_WEBSITE =>
|
||||||
[
|
[
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'scope' => self::VISIBILITY_PRIVATE,
|
'scope' => self::SCOPE_LOCAL,
|
||||||
'verified' => self::NOT_VERIFIED,
|
'verified' => self::NOT_VERIFIED,
|
||||||
],
|
],
|
||||||
self::PROPERTY_EMAIL =>
|
self::PROPERTY_EMAIL =>
|
||||||
[
|
[
|
||||||
'value' => $user->getEMailAddress(),
|
'value' => $user->getEMailAddress(),
|
||||||
'scope' => self::VISIBILITY_CONTACTS_ONLY,
|
'scope' => self::SCOPE_FEDERATED,
|
||||||
'verified' => self::NOT_VERIFIED,
|
'verified' => self::NOT_VERIFIED,
|
||||||
],
|
],
|
||||||
self::PROPERTY_AVATAR =>
|
self::PROPERTY_AVATAR =>
|
||||||
[
|
[
|
||||||
'scope' => self::VISIBILITY_CONTACTS_ONLY
|
'scope' => self::SCOPE_FEDERATED
|
||||||
],
|
],
|
||||||
self::PROPERTY_PHONE =>
|
self::PROPERTY_PHONE =>
|
||||||
[
|
[
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'scope' => self::VISIBILITY_PRIVATE,
|
'scope' => self::SCOPE_LOCAL,
|
||||||
'verified' => self::NOT_VERIFIED,
|
'verified' => self::NOT_VERIFIED,
|
||||||
],
|
],
|
||||||
self::PROPERTY_TWITTER =>
|
self::PROPERTY_TWITTER =>
|
||||||
[
|
[
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'scope' => self::VISIBILITY_PRIVATE,
|
'scope' => self::SCOPE_LOCAL,
|
||||||
'verified' => self::NOT_VERIFIED,
|
'verified' => self::NOT_VERIFIED,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -464,7 +464,7 @@ class AccountManager implements IAccountManager {
|
||||||
private function parseAccountData(IUser $user, $data): Account {
|
private function parseAccountData(IUser $user, $data): Account {
|
||||||
$account = new Account($user);
|
$account = new Account($user);
|
||||||
foreach ($data as $property => $accountData) {
|
foreach ($data as $property => $accountData) {
|
||||||
$account->setProperty($property, $accountData['value'] ?? '', $accountData['scope'] ?? self::VISIBILITY_PRIVATE, $accountData['verified'] ?? self::NOT_VERIFIED);
|
$account->setProperty($property, $accountData['value'] ?? '', $accountData['scope'] ?? self::SCOPE_LOCAL, $accountData['verified'] ?? self::NOT_VERIFIED);
|
||||||
}
|
}
|
||||||
return $account;
|
return $account;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace OC\Accounts;
|
namespace OC\Accounts;
|
||||||
|
|
||||||
|
use OCP\Accounts\IAccountManager;
|
||||||
use OCP\Accounts\IAccountProperty;
|
use OCP\Accounts\IAccountProperty;
|
||||||
|
|
||||||
class AccountProperty implements IAccountProperty {
|
class AccountProperty implements IAccountProperty {
|
||||||
|
@ -42,7 +43,7 @@ class AccountProperty implements IAccountProperty {
|
||||||
public function __construct(string $name, string $value, string $scope, string $verified) {
|
public function __construct(string $name, string $value, string $scope, string $verified) {
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
$this->scope = $scope;
|
$this->scope = $this->mapScopeToV2($scope);
|
||||||
$this->verified = $verified;
|
$this->verified = $verified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ class AccountProperty implements IAccountProperty {
|
||||||
* @return IAccountProperty
|
* @return IAccountProperty
|
||||||
*/
|
*/
|
||||||
public function setScope(string $scope): IAccountProperty {
|
public function setScope(string $scope): IAccountProperty {
|
||||||
$this->scope = $scope;
|
$this->scope = $this->mapScopeToV2($scope);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +128,23 @@ class AccountProperty implements IAccountProperty {
|
||||||
return $this->scope;
|
return $this->scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function mapScopeToV2($scope) {
|
||||||
|
if (strpos($scope, 'v2-') === 0) {
|
||||||
|
return $scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($scope) {
|
||||||
|
case IAccountManager::VISIBILITY_PRIVATE:
|
||||||
|
return IAccountManager::SCOPE_LOCAL;
|
||||||
|
case IAccountManager::VISIBILITY_CONTACTS_ONLY:
|
||||||
|
return IAccountManager::SCOPE_FEDERATED;
|
||||||
|
case IAccountManager::VISIBILITY_PUBLIC:
|
||||||
|
return IAccountManager::SCOPE_PUBLISHED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return IAccountManager::SCOPE_LOCAL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the verification status of a property
|
* Get the verification status of a property
|
||||||
*
|
*
|
||||||
|
|
|
@ -50,14 +50,14 @@ interface IAccountManager {
|
||||||
*
|
*
|
||||||
* @since 21.0.1
|
* @since 21.0.1
|
||||||
*/
|
*/
|
||||||
public const SCOPE_LOCAL = 'private';
|
public const SCOPE_LOCAL = 'v2-local';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contact details visible locally, through public link access and on trusted federated servers.
|
* Contact details visible locally, through public link access and on trusted federated servers.
|
||||||
*
|
*
|
||||||
* @since 21.0.1
|
* @since 21.0.1
|
||||||
*/
|
*/
|
||||||
public const SCOPE_FEDERATED = 'federated';
|
public const SCOPE_FEDERATED = 'v2-federated';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contact details visible locally, through public link access, on trusted federated servers
|
* Contact details visible locally, through public link access, on trusted federated servers
|
||||||
|
@ -65,7 +65,7 @@ interface IAccountManager {
|
||||||
*
|
*
|
||||||
* @since 21.0.1
|
* @since 21.0.1
|
||||||
*/
|
*/
|
||||||
public const SCOPE_PUBLISHED = 'public';
|
public const SCOPE_PUBLISHED = 'v2-published';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contact details only visible locally
|
* Contact details only visible locally
|
||||||
|
|
|
@ -278,26 +278,26 @@ class AccountManagerTest extends TestCase {
|
||||||
IAccountManager::PROPERTY_TWITTER =>
|
IAccountManager::PROPERTY_TWITTER =>
|
||||||
[
|
[
|
||||||
'value' => '@twitterhandle',
|
'value' => '@twitterhandle',
|
||||||
'scope' => IAccountManager::VISIBILITY_PRIVATE,
|
'scope' => IAccountManager::SCOPE_LOCAL,
|
||||||
'verified' => IAccountManager::NOT_VERIFIED,
|
'verified' => IAccountManager::NOT_VERIFIED,
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_EMAIL =>
|
IAccountManager::PROPERTY_EMAIL =>
|
||||||
[
|
[
|
||||||
'value' => 'test@example.com',
|
'value' => 'test@example.com',
|
||||||
'scope' => IAccountManager::VISIBILITY_PUBLIC,
|
'scope' => IAccountManager::SCOPE_PUBLISHED,
|
||||||
'verified' => IAccountManager::VERIFICATION_IN_PROGRESS,
|
'verified' => IAccountManager::VERIFICATION_IN_PROGRESS,
|
||||||
],
|
],
|
||||||
IAccountManager::PROPERTY_WEBSITE =>
|
IAccountManager::PROPERTY_WEBSITE =>
|
||||||
[
|
[
|
||||||
'value' => 'https://example.com',
|
'value' => 'https://example.com',
|
||||||
'scope' => IAccountManager::VISIBILITY_CONTACTS_ONLY,
|
'scope' => IAccountManager::SCOPE_FEDERATED,
|
||||||
'verified' => IAccountManager::VERIFIED,
|
'verified' => IAccountManager::VERIFIED,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$expected = new Account($user);
|
$expected = new Account($user);
|
||||||
$expected->setProperty(IAccountManager::PROPERTY_TWITTER, '@twitterhandle', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::NOT_VERIFIED);
|
$expected->setProperty(IAccountManager::PROPERTY_TWITTER, '@twitterhandle', IAccountManager::SCOPE_LOCAL, IAccountManager::NOT_VERIFIED);
|
||||||
$expected->setProperty(IAccountManager::PROPERTY_EMAIL, 'test@example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::VERIFICATION_IN_PROGRESS);
|
$expected->setProperty(IAccountManager::PROPERTY_EMAIL, 'test@example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFICATION_IN_PROGRESS);
|
||||||
$expected->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_CONTACTS_ONLY, IAccountManager::VERIFIED);
|
$expected->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_FEDERATED, IAccountManager::VERIFIED);
|
||||||
|
|
||||||
$accountManager->expects($this->once())
|
$accountManager->expects($this->once())
|
||||||
->method('getUser')
|
->method('getUser')
|
||||||
|
|
|
@ -37,12 +37,12 @@ class AccountPropertyTest extends TestCase {
|
||||||
$accountProperty = new AccountProperty(
|
$accountProperty = new AccountProperty(
|
||||||
IAccountManager::PROPERTY_WEBSITE,
|
IAccountManager::PROPERTY_WEBSITE,
|
||||||
'https://example.com',
|
'https://example.com',
|
||||||
IAccountManager::VISIBILITY_PUBLIC,
|
IAccountManager::SCOPE_PUBLISHED,
|
||||||
IAccountManager::VERIFIED
|
IAccountManager::VERIFIED
|
||||||
);
|
);
|
||||||
$this->assertEquals(IAccountManager::PROPERTY_WEBSITE, $accountProperty->getName());
|
$this->assertEquals(IAccountManager::PROPERTY_WEBSITE, $accountProperty->getName());
|
||||||
$this->assertEquals('https://example.com', $accountProperty->getValue());
|
$this->assertEquals('https://example.com', $accountProperty->getValue());
|
||||||
$this->assertEquals(IAccountManager::VISIBILITY_PUBLIC, $accountProperty->getScope());
|
$this->assertEquals(IAccountManager::SCOPE_PUBLISHED, $accountProperty->getScope());
|
||||||
$this->assertEquals(IAccountManager::VERIFIED, $accountProperty->getVerified());
|
$this->assertEquals(IAccountManager::VERIFIED, $accountProperty->getVerified());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class AccountPropertyTest extends TestCase {
|
||||||
$accountProperty = new AccountProperty(
|
$accountProperty = new AccountProperty(
|
||||||
IAccountManager::PROPERTY_WEBSITE,
|
IAccountManager::PROPERTY_WEBSITE,
|
||||||
'https://example.com',
|
'https://example.com',
|
||||||
IAccountManager::VISIBILITY_PUBLIC,
|
IAccountManager::SCOPE_PUBLISHED,
|
||||||
IAccountManager::VERIFIED
|
IAccountManager::VERIFIED
|
||||||
);
|
);
|
||||||
$actualReturn = $accountProperty->setValue('https://example.org');
|
$actualReturn = $accountProperty->setValue('https://example.org');
|
||||||
|
@ -62,19 +62,48 @@ class AccountPropertyTest extends TestCase {
|
||||||
$accountProperty = new AccountProperty(
|
$accountProperty = new AccountProperty(
|
||||||
IAccountManager::PROPERTY_WEBSITE,
|
IAccountManager::PROPERTY_WEBSITE,
|
||||||
'https://example.com',
|
'https://example.com',
|
||||||
IAccountManager::VISIBILITY_PUBLIC,
|
IAccountManager::SCOPE_PUBLISHED,
|
||||||
IAccountManager::VERIFIED
|
IAccountManager::VERIFIED
|
||||||
);
|
);
|
||||||
$actualReturn = $accountProperty->setScope(IAccountManager::VISIBILITY_PRIVATE);
|
$actualReturn = $accountProperty->setScope(IAccountManager::SCOPE_LOCAL);
|
||||||
$this->assertEquals(IAccountManager::VISIBILITY_PRIVATE, $accountProperty->getScope());
|
$this->assertEquals(IAccountManager::SCOPE_LOCAL, $accountProperty->getScope());
|
||||||
$this->assertEquals(IAccountManager::VISIBILITY_PRIVATE, $actualReturn->getScope());
|
$this->assertEquals(IAccountManager::SCOPE_LOCAL, $actualReturn->getScope());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopesProvider() {
|
||||||
|
return [
|
||||||
|
// current values
|
||||||
|
[IAccountManager::SCOPE_PRIVATE, IAccountManager::SCOPE_PRIVATE],
|
||||||
|
[IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_LOCAL],
|
||||||
|
[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],
|
||||||
|
// fallback
|
||||||
|
['', IAccountManager::SCOPE_LOCAL],
|
||||||
|
['unknown', IAccountManager::SCOPE_LOCAL],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider scopesProvider
|
||||||
|
*/
|
||||||
|
public function testSetScopeMapping($storedScope, $returnedScope) {
|
||||||
|
$accountProperty = new AccountProperty(
|
||||||
|
IAccountManager::PROPERTY_WEBSITE,
|
||||||
|
'https://example.com',
|
||||||
|
$storedScope,
|
||||||
|
IAccountManager::VERIFIED
|
||||||
|
);
|
||||||
|
$this->assertEquals($returnedScope, $accountProperty->getScope());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetVerified() {
|
public function testSetVerified() {
|
||||||
$accountProperty = new AccountProperty(
|
$accountProperty = new AccountProperty(
|
||||||
IAccountManager::PROPERTY_WEBSITE,
|
IAccountManager::PROPERTY_WEBSITE,
|
||||||
'https://example.com',
|
'https://example.com',
|
||||||
IAccountManager::VISIBILITY_PUBLIC,
|
IAccountManager::SCOPE_PUBLISHED,
|
||||||
IAccountManager::VERIFIED
|
IAccountManager::VERIFIED
|
||||||
);
|
);
|
||||||
$actualReturn = $accountProperty->setVerified(IAccountManager::NOT_VERIFIED);
|
$actualReturn = $accountProperty->setVerified(IAccountManager::NOT_VERIFIED);
|
||||||
|
@ -86,13 +115,13 @@ class AccountPropertyTest extends TestCase {
|
||||||
$accountProperty = new AccountProperty(
|
$accountProperty = new AccountProperty(
|
||||||
IAccountManager::PROPERTY_WEBSITE,
|
IAccountManager::PROPERTY_WEBSITE,
|
||||||
'https://example.com',
|
'https://example.com',
|
||||||
IAccountManager::VISIBILITY_PUBLIC,
|
IAccountManager::SCOPE_PUBLISHED,
|
||||||
IAccountManager::VERIFIED
|
IAccountManager::VERIFIED
|
||||||
);
|
);
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'name' => IAccountManager::PROPERTY_WEBSITE,
|
'name' => IAccountManager::PROPERTY_WEBSITE,
|
||||||
'value' => 'https://example.com',
|
'value' => 'https://example.com',
|
||||||
'scope' => IAccountManager::VISIBILITY_PUBLIC,
|
'scope' => IAccountManager::SCOPE_PUBLISHED,
|
||||||
'verified' => IAccountManager::VERIFIED
|
'verified' => IAccountManager::VERIFIED
|
||||||
], $accountProperty->jsonSerialize());
|
], $accountProperty->jsonSerialize());
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,21 +43,21 @@ class AccountTest extends TestCase {
|
||||||
|
|
||||||
public function testSetProperty() {
|
public function testSetProperty() {
|
||||||
$user = $this->createMock(IUser::class);
|
$user = $this->createMock(IUser::class);
|
||||||
$property = new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED);
|
$property = new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED);
|
||||||
$account = new Account($user);
|
$account = new Account($user);
|
||||||
$account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED);
|
$account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED);
|
||||||
$this->assertEquals($property, $account->getProperty(IAccountManager::PROPERTY_WEBSITE));
|
$this->assertEquals($property, $account->getProperty(IAccountManager::PROPERTY_WEBSITE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetProperties() {
|
public function testGetProperties() {
|
||||||
$user = $this->createMock(IUser::class);
|
$user = $this->createMock(IUser::class);
|
||||||
$properties = [
|
$properties = [
|
||||||
IAccountManager::PROPERTY_WEBSITE => new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED),
|
IAccountManager::PROPERTY_WEBSITE => new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED),
|
||||||
IAccountManager::PROPERTY_EMAIL => new AccountProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED)
|
IAccountManager::PROPERTY_EMAIL => new AccountProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::SCOPE_LOCAL, IAccountManager::VERIFIED)
|
||||||
];
|
];
|
||||||
$account = new Account($user);
|
$account = new Account($user);
|
||||||
$account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED);
|
$account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED);
|
||||||
$account->setProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED);
|
$account->setProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::SCOPE_LOCAL, IAccountManager::VERIFIED);
|
||||||
|
|
||||||
$this->assertEquals($properties, $account->getProperties());
|
$this->assertEquals($properties, $account->getProperties());
|
||||||
}
|
}
|
||||||
|
@ -65,14 +65,14 @@ class AccountTest extends TestCase {
|
||||||
public function testGetFilteredProperties() {
|
public function testGetFilteredProperties() {
|
||||||
$user = $this->createMock(IUser::class);
|
$user = $this->createMock(IUser::class);
|
||||||
$properties = [
|
$properties = [
|
||||||
IAccountManager::PROPERTY_WEBSITE => new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED),
|
IAccountManager::PROPERTY_WEBSITE => new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED),
|
||||||
IAccountManager::PROPERTY_EMAIL => new AccountProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED),
|
IAccountManager::PROPERTY_EMAIL => new AccountProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::SCOPE_LOCAL, IAccountManager::VERIFIED),
|
||||||
IAccountManager::PROPERTY_PHONE => new AccountProperty(IAccountManager::PROPERTY_PHONE, '123456', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::VERIFIED),
|
IAccountManager::PROPERTY_PHONE => new AccountProperty(IAccountManager::PROPERTY_PHONE, '123456', IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFIED),
|
||||||
];
|
];
|
||||||
$account = new Account($user);
|
$account = new Account($user);
|
||||||
$account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED);
|
$account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED);
|
||||||
$account->setProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED);
|
$account->setProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::SCOPE_LOCAL, IAccountManager::VERIFIED);
|
||||||
$account->setProperty(IAccountManager::PROPERTY_PHONE, '123456', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::VERIFIED);
|
$account->setProperty(IAccountManager::PROPERTY_PHONE, '123456', IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFIED);
|
||||||
|
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
|
@ -80,7 +80,7 @@ class AccountTest extends TestCase {
|
||||||
IAccountManager::PROPERTY_WEBSITE => $properties[IAccountManager::PROPERTY_WEBSITE],
|
IAccountManager::PROPERTY_WEBSITE => $properties[IAccountManager::PROPERTY_WEBSITE],
|
||||||
IAccountManager::PROPERTY_PHONE => $properties[IAccountManager::PROPERTY_PHONE],
|
IAccountManager::PROPERTY_PHONE => $properties[IAccountManager::PROPERTY_PHONE],
|
||||||
],
|
],
|
||||||
$account->getFilteredProperties(IAccountManager::VISIBILITY_PUBLIC)
|
$account->getFilteredProperties(IAccountManager::SCOPE_PUBLISHED)
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
[
|
[
|
||||||
|
@ -91,19 +91,19 @@ class AccountTest extends TestCase {
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
[IAccountManager::PROPERTY_PHONE => $properties[IAccountManager::PROPERTY_PHONE]],
|
[IAccountManager::PROPERTY_PHONE => $properties[IAccountManager::PROPERTY_PHONE]],
|
||||||
$account->getFilteredProperties(IAccountManager::VISIBILITY_PUBLIC, IAccountManager::VERIFIED)
|
$account->getFilteredProperties(IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFIED)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testJsonSerialize() {
|
public function testJsonSerialize() {
|
||||||
$user = $this->createMock(IUser::class);
|
$user = $this->createMock(IUser::class);
|
||||||
$properties = [
|
$properties = [
|
||||||
IAccountManager::PROPERTY_WEBSITE => new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED),
|
IAccountManager::PROPERTY_WEBSITE => new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED),
|
||||||
IAccountManager::PROPERTY_EMAIL => new AccountProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED)
|
IAccountManager::PROPERTY_EMAIL => new AccountProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::SCOPE_LOCAL, IAccountManager::VERIFIED)
|
||||||
];
|
];
|
||||||
$account = new Account($user);
|
$account = new Account($user);
|
||||||
$account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED);
|
$account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED);
|
||||||
$account->setProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED);
|
$account->setProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::SCOPE_LOCAL, IAccountManager::VERIFIED);
|
||||||
|
|
||||||
$this->assertEquals($properties, $account->jsonSerialize());
|
$this->assertEquals($properties, $account->jsonSerialize());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue