Skip to content

Commit 602de27

Browse files
Merge pull request #26243 from nextcloud/enh/noid/avatar-privacy-new-scope
Avatar privacy and new scope
2 parents 4564121 + 00d83a5 commit 602de27

File tree

38 files changed

+1266
-277
lines changed

38 files changed

+1266
-277
lines changed

apps/dav/lib/CardDAV/Converter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public function createCardFromUser(IUser $user) {
7171

7272
foreach ($userData as $property => $value) {
7373
$shareWithTrustedServers =
74-
$value['scope'] === AccountManager::VISIBILITY_CONTACTS_ONLY ||
75-
$value['scope'] === AccountManager::VISIBILITY_PUBLIC;
74+
$value['scope'] === AccountManager::SCOPE_FEDERATED ||
75+
$value['scope'] === AccountManager::SCOPE_PUBLISHED;
7676

7777
$emptyValue = !isset($value['value']) || $value['value'] === '';
7878

apps/dav/tests/unit/CardDAV/ConverterTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,36 +53,36 @@ public function getAccountManager(IUser $user) {
5353
IAccountManager::PROPERTY_DISPLAYNAME =>
5454
[
5555
'value' => $user->getDisplayName(),
56-
'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY,
56+
'scope' => AccountManager::SCOPE_FEDERATED,
5757
],
5858
IAccountManager::PROPERTY_ADDRESS =>
5959
[
6060
'value' => '',
61-
'scope' => AccountManager::VISIBILITY_PRIVATE,
61+
'scope' => AccountManager::SCOPE_LOCAL,
6262
],
6363
IAccountManager::PROPERTY_WEBSITE =>
6464
[
6565
'value' => '',
66-
'scope' => AccountManager::VISIBILITY_PRIVATE,
66+
'scope' => AccountManager::SCOPE_LOCAL,
6767
],
6868
IAccountManager::PROPERTY_EMAIL =>
6969
[
7070
'value' => $user->getEMailAddress(),
71-
'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY,
71+
'scope' => AccountManager::SCOPE_FEDERATED,
7272
],
7373
IAccountManager::PROPERTY_AVATAR =>
7474
[
75-
'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY
75+
'scope' => AccountManager::SCOPE_FEDERATED
7676
],
7777
IAccountManager::PROPERTY_PHONE =>
7878
[
7979
'value' => '',
80-
'scope' => AccountManager::VISIBILITY_PRIVATE,
80+
'scope' => AccountManager::SCOPE_LOCAL,
8181
],
8282
IAccountManager::PROPERTY_TWITTER =>
8383
[
8484
'value' => '',
85-
'scope' => AccountManager::VISIBILITY_PRIVATE,
85+
'scope' => AccountManager::SCOPE_LOCAL,
8686
],
8787
]
8888
);

apps/dav/tests/unit/CardDAV/SyncServiceTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,36 +136,36 @@ public function testUpdateAndDeleteUser($activated, $createCalls, $updateCalls,
136136
IAccountManager::PROPERTY_DISPLAYNAME =>
137137
[
138138
'value' => $user->getDisplayName(),
139-
'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY,
139+
'scope' => AccountManager::SCOPE_FEDERATED,
140140
],
141141
IAccountManager::PROPERTY_ADDRESS =>
142142
[
143143
'value' => '',
144-
'scope' => AccountManager::VISIBILITY_PRIVATE,
144+
'scope' => AccountManager::SCOPE_LOCAL,
145145
],
146146
IAccountManager::PROPERTY_WEBSITE =>
147147
[
148148
'value' => '',
149-
'scope' => AccountManager::VISIBILITY_PRIVATE,
149+
'scope' => AccountManager::SCOPE_LOCAL,
150150
],
151151
IAccountManager::PROPERTY_EMAIL =>
152152
[
153153
'value' => $user->getEMailAddress(),
154-
'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY,
154+
'scope' => AccountManager::SCOPE_FEDERATED,
155155
],
156156
IAccountManager::PROPERTY_AVATAR =>
157157
[
158-
'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY
158+
'scope' => AccountManager::SCOPE_FEDERATED
159159
],
160160
IAccountManager::PROPERTY_PHONE =>
161161
[
162162
'value' => '',
163-
'scope' => AccountManager::VISIBILITY_PRIVATE,
163+
'scope' => AccountManager::SCOPE_LOCAL,
164164
],
165165
IAccountManager::PROPERTY_TWITTER =>
166166
[
167167
'value' => '',
168-
'scope' => AccountManager::VISIBILITY_PRIVATE,
168+
'scope' => AccountManager::SCOPE_LOCAL,
169169
],
170170
]
171171
);

apps/files_sharing/lib/Controller/ShareController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ public function showShare($path = ''): TemplateResponse {
343343
$ownerAccount = $this->accountManager->getAccount($owner);
344344

345345
$ownerName = $ownerAccount->getProperty(IAccountManager::PROPERTY_DISPLAYNAME);
346-
if ($ownerName->getScope() === IAccountManager::VISIBILITY_PUBLIC) {
346+
if ($ownerName->getScope() === IAccountManager::SCOPE_PUBLISHED) {
347347
$shareTmpl['owner'] = $owner->getUID();
348348
$shareTmpl['shareOwner'] = $owner->getDisplayName();
349349
}

apps/files_sharing/tests/Controller/ShareControllerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public function testShowShare() {
234234

235235
$accountName = $this->createMock(IAccountProperty::class);
236236
$accountName->method('getScope')
237-
->willReturn(IAccountManager::VISIBILITY_PUBLIC);
237+
->willReturn(IAccountManager::SCOPE_PUBLISHED);
238238
$account = $this->createMock(IAccount::class);
239239
$account->method('getProperty')
240240
->with(IAccountManager::PROPERTY_DISPLAYNAME)
@@ -381,7 +381,7 @@ public function testShowShareWithPrivateName() {
381381

382382
$accountName = $this->createMock(IAccountProperty::class);
383383
$accountName->method('getScope')
384-
->willReturn(IAccountManager::VISIBILITY_PRIVATE);
384+
->willReturn(IAccountManager::SCOPE_LOCAL);
385385
$account = $this->createMock(IAccount::class);
386386
$account->method('getProperty')
387387
->with(IAccountManager::PROPERTY_DISPLAYNAME)
@@ -528,7 +528,7 @@ public function testShowShareHideDownload() {
528528

529529
$accountName = $this->createMock(IAccountProperty::class);
530530
$accountName->method('getScope')
531-
->willReturn(IAccountManager::VISIBILITY_PUBLIC);
531+
->willReturn(IAccountManager::SCOPE_PUBLISHED);
532532
$account = $this->createMock(IAccount::class);
533533
$account->method('getProperty')
534534
->with(IAccountManager::PROPERTY_DISPLAYNAME)
@@ -688,7 +688,7 @@ public function testShareFileDrop() {
688688

689689
$accountName = $this->createMock(IAccountProperty::class);
690690
$accountName->method('getScope')
691-
->willReturn(IAccountManager::VISIBILITY_PUBLIC);
691+
->willReturn(IAccountManager::SCOPE_PUBLISHED);
692692
$account = $this->createMock(IAccount::class);
693693
$account->method('getProperty')
694694
->with(IAccountManager::PROPERTY_DISPLAYNAME)

apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ protected function getUserAccountData(IUser $user): array {
193193

194194
$publicData = [];
195195
foreach ($account->getProperties() as $property) {
196-
if ($property->getScope() === IAccountManager::VISIBILITY_PUBLIC) {
196+
if ($property->getScope() === IAccountManager::SCOPE_PUBLISHED) {
197197
$publicData[$property->getName()] = $property->getValue();
198198
}
199199
}

apps/provisioning_api/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
return array(
99
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
1010
'OCA\\Provisioning_API\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
11+
'OCA\\Provisioning_API\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
1112
'OCA\\Provisioning_API\\Controller\\AUserData' => $baseDir . '/../lib/Controller/AUserData.php',
1213
'OCA\\Provisioning_API\\Controller\\AppConfigController' => $baseDir . '/../lib/Controller/AppConfigController.php',
1314
'OCA\\Provisioning_API\\Controller\\AppsController' => $baseDir . '/../lib/Controller/AppsController.php',

apps/provisioning_api/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class ComposerStaticInitProvisioning_API
2323
public static $classMap = array (
2424
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
2525
'OCA\\Provisioning_API\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
26+
'OCA\\Provisioning_API\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
2627
'OCA\\Provisioning_API\\Controller\\AUserData' => __DIR__ . '/..' . '/../lib/Controller/AUserData.php',
2728
'OCA\\Provisioning_API\\Controller\\AppConfigController' => __DIR__ . '/..' . '/../lib/Controller/AppConfigController.php',
2829
'OCA\\Provisioning_API\\Controller\\AppsController' => __DIR__ . '/..' . '/../lib/Controller/AppsController.php',

apps/provisioning_api/lib/AppInfo/Application.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
namespace OCA\Provisioning_API\AppInfo;
3030

3131
use OC\Group\Manager as GroupManager;
32+
use OCA\Provisioning_API\Capabilities;
3233
use OCA\Provisioning_API\Listener\UserDeletedListener;
3334
use OCA\Provisioning_API\Middleware\ProvisioningApiMiddleware;
3435
use OCA\Settings\Mailer\NewUserMailHelper;
@@ -92,6 +93,7 @@ public function register(IRegistrationContext $context): void {
9293
);
9394
});
9495
$context->registerMiddleware(ProvisioningApiMiddleware::class);
96+
$context->registerCapability(Capabilities::class);
9597
}
9698

9799
public function boot(IBootContext $context): void {
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 2021 Vincent Petry <vincent@nextcloud.com>
4+
*
5+
* @author Vincent Petry <vincent@nextcloud.com>
6+
*
7+
* @license GNU AGPL version 3 or any later version
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
23+
24+
namespace OCA\Provisioning_API;
25+
26+
use OCA\FederatedFileSharing\FederatedShareProvider;
27+
use OCP\App\IAppManager;
28+
use OCP\Capabilities\ICapability;
29+
30+
class Capabilities implements ICapability {
31+
32+
/** @var IAppManager */
33+
private $appManager;
34+
35+
public function __construct(IAppManager $appManager) {
36+
$this->appManager = $appManager;
37+
}
38+
39+
/**
40+
* Function an app uses to return the capabilities
41+
*
42+
* @return array Array containing the apps capabilities
43+
*/
44+
public function getCapabilities() {
45+
$federationScopesEnabled = false;
46+
47+
$federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing');
48+
if ($federatedFileSharingEnabled) {
49+
/** @var FederatedShareProvider $shareProvider */
50+
$shareProvider = \OC::$server->query(FederatedShareProvider::class);
51+
$federationScopesEnabled = $shareProvider->isLookupServerUploadEnabled();
52+
}
53+
54+
return [
55+
'provisioning_api' => [
56+
'version' => $this->appManager->getAppVersion('provisioning_api'),
57+
'AccountPropertyScopesVersion' => 2,
58+
'AccountPropertyScopesFederationEnabled' => $federationScopesEnabled,
59+
]
60+
];
61+
}
62+
}

0 commit comments

Comments
 (0)