Skip to content

Commit 78d6206

Browse files
authored
Merge pull request #28422 from nextcloud/enh/27465/notification-email
2 parents 347b59f + 763136a commit 78d6206

File tree

46 files changed

+1422
-448
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1422
-448
lines changed

apps/dav/lib/Connector/Sabre/Principal.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,16 +300,13 @@ protected function searchUserPrincipals(array $searchProperties, $test = 'allof'
300300
if (!$allowEnumeration) {
301301
if ($allowEnumerationFullMatch) {
302302
$users = $this->userManager->getByEmail($value);
303-
$users = \array_filter($users, static function (IUser $user) use ($value) {
304-
return $user->getEMailAddress() === $value;
305-
});
306303
} else {
307304
$users = [];
308305
}
309306
} else {
310307
$users = $this->userManager->getByEmail($value);
311308
$users = \array_filter($users, function (IUser $user) use ($currentUser, $value, $limitEnumerationPhone, $limitEnumerationGroup, $allowEnumerationFullMatch, $currentUserGroups) {
312-
if ($allowEnumerationFullMatch && $user->getEMailAddress() === $value) {
309+
if ($allowEnumerationFullMatch && $user->getSystemEMailAddress() === $value) {
313310
return true;
314311
}
315312

@@ -516,7 +513,7 @@ protected function userToPrincipal($user) {
516513
'{http://nextcloud.com/ns}language' => $this->languageFactory->getUserLanguage($user),
517514
];
518515

519-
$email = $user->getEMailAddress();
516+
$email = $user->getSystemEMailAddress();
520517
if (!empty($email)) {
521518
$principal['{http://sabredav.org/ns}email-address'] = $email;
522519
}

apps/dav/lib/DAV/GroupPrincipalBackend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ protected function userToPrincipal($user) {
331331
'{urn:ietf:params:xml:ns:caldav}calendar-user-type' => 'INDIVIDUAL',
332332
];
333333

334-
$email = $user->getEMailAddress();
334+
$email = $user->getSystemEMailAddress();
335335
if (!empty($email)) {
336336
$principal['{http://sabredav.org/ns}email-address'] = $email;
337337
}

apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function testGetPrincipalsByPrefixWithUsers(): void {
120120
->willReturn('Dr. Foo-Bar');
121121
$fooUser
122122
->expects($this->once())
123-
->method('getEMailAddress')
123+
->method('getSystemEMailAddress')
124124
->willReturn('');
125125
$barUser = $this->createMock(User::class);
126126
$barUser
@@ -129,7 +129,7 @@ public function testGetPrincipalsByPrefixWithUsers(): void {
129129
->willReturn('bar');
130130
$barUser
131131
->expects($this->once())
132-
->method('getEMailAddress')
132+
->method('getSystemEMailAddress')
133133
->willReturn('bar@nextcloud.com');
134134
$this->userManager
135135
->expects($this->once())
@@ -205,7 +205,7 @@ public function testGetPrincipalsByPathWithMail(): void {
205205
$fooUser = $this->createMock(User::class);
206206
$fooUser
207207
->expects($this->once())
208-
->method('getEMailAddress')
208+
->method('getSystemEMailAddress')
209209
->willReturn('foo@nextcloud.com');
210210
$fooUser
211211
->expects($this->once())
@@ -605,15 +605,15 @@ public function testSearchPrincipalWithEnumerationDisabledDisplayname(): void {
605605
$user2 = $this->createMock(IUser::class);
606606
$user2->method('getUID')->willReturn('user2');
607607
$user2->method('getDisplayName')->willReturn('User 2');
608-
$user2->method('getEMailAddress')->willReturn('user2@foo.bar');
608+
$user2->method('getSystemEMailAddress')->willReturn('user2@foo.bar');
609609
$user3 = $this->createMock(IUser::class);
610610
$user3->method('getUID')->willReturn('user3');
611611
$user2->method('getDisplayName')->willReturn('User 22');
612-
$user2->method('getEMailAddress')->willReturn('user2@foo.bar123');
612+
$user2->method('getSystemEMailAddress')->willReturn('user2@foo.bar123');
613613
$user4 = $this->createMock(IUser::class);
614614
$user4->method('getUID')->willReturn('user4');
615615
$user2->method('getDisplayName')->willReturn('User 222');
616-
$user2->method('getEMailAddress')->willReturn('user2@foo.bar456');
616+
$user2->method('getSystemEMailAddress')->willReturn('user2@foo.bar456');
617617

618618
$this->userManager->expects($this->at(0))
619619
->method('searchDisplayName')
@@ -665,20 +665,20 @@ public function testSearchPrincipalWithEnumerationDisabledEmail(): void {
665665
$user2 = $this->createMock(IUser::class);
666666
$user2->method('getUID')->willReturn('user2');
667667
$user2->method('getDisplayName')->willReturn('User 2');
668-
$user2->method('getEMailAddress')->willReturn('user2@foo.bar');
668+
$user2->method('getSystemEMailAddress')->willReturn('user2@foo.bar');
669669
$user3 = $this->createMock(IUser::class);
670670
$user3->method('getUID')->willReturn('user3');
671671
$user2->method('getDisplayName')->willReturn('User 22');
672-
$user2->method('getEMailAddress')->willReturn('user2@foo.bar123');
672+
$user2->method('getSystemEMailAddress')->willReturn('user2@foo.bar123');
673673
$user4 = $this->createMock(IUser::class);
674674
$user4->method('getUID')->willReturn('user4');
675675
$user2->method('getDisplayName')->willReturn('User 222');
676-
$user2->method('getEMailAddress')->willReturn('user2@foo.bar456');
676+
$user2->method('getSystemEMailAddress')->willReturn('user2@foo.bar456');
677677

678-
$this->userManager->expects($this->at(0))
678+
$this->userManager->expects($this->once())
679679
->method('getByEmail')
680680
->with('user2@foo.bar')
681-
->willReturn([$user2, $user3, $user4]);
681+
->willReturn([$user2]);
682682

683683
$this->assertEquals(['principals/users/user2'], $this->connector->searchPrincipals('principals/users',
684684
['{http://sabredav.org/ns}email-address' => 'user2@foo.bar']));
@@ -726,15 +726,15 @@ public function testSearchPrincipalWithEnumerationLimitedDisplayname(): void {
726726
$user2 = $this->createMock(IUser::class);
727727
$user2->method('getUID')->willReturn('user2');
728728
$user2->method('getDisplayName')->willReturn('User 2');
729-
$user2->method('getEMailAddress')->willReturn('user2@foo.bar');
729+
$user2->method('getSystemEMailAddress')->willReturn('user2@foo.bar');
730730
$user3 = $this->createMock(IUser::class);
731731
$user3->method('getUID')->willReturn('user3');
732732
$user3->method('getDisplayName')->willReturn('User 22');
733-
$user3->method('getEMailAddress')->willReturn('user2@foo.bar123');
733+
$user3->method('getSystemEMailAddress')->willReturn('user2@foo.bar123');
734734
$user4 = $this->createMock(IUser::class);
735735
$user4->method('getUID')->willReturn('user4');
736736
$user4->method('getDisplayName')->willReturn('User 222');
737-
$user4->method('getEMailAddress')->willReturn('user2@foo.bar456');
737+
$user4->method('getSystemEMailAddress')->willReturn('user2@foo.bar456');
738738

739739

740740
$this->userSession->expects($this->at(0))
@@ -787,15 +787,15 @@ public function testSearchPrincipalWithEnumerationLimitedMail(): void {
787787
$user2 = $this->createMock(IUser::class);
788788
$user2->method('getUID')->willReturn('user2');
789789
$user2->method('getDisplayName')->willReturn('User 2');
790-
$user2->method('getEMailAddress')->willReturn('user2@foo.bar');
790+
$user2->method('getSystemEMailAddress')->willReturn('user2@foo.bar');
791791
$user3 = $this->createMock(IUser::class);
792792
$user3->method('getUID')->willReturn('user3');
793793
$user3->method('getDisplayName')->willReturn('User 22');
794-
$user3->method('getEMailAddress')->willReturn('user2@foo.bar123');
794+
$user3->method('getSystemEMailAddress')->willReturn('user2@foo.bar123');
795795
$user4 = $this->createMock(IUser::class);
796796
$user4->method('getUID')->willReturn('user4');
797797
$user4->method('getDisplayName')->willReturn('User 222');
798-
$user4->method('getEMailAddress')->willReturn('user2@foo.bar456');
798+
$user4->method('getSystemEMailAddress')->willReturn('user2@foo.bar456');
799799

800800

801801
$this->userSession->expects($this->at(0))

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ protected function formatShare(IShare $share, Node $recipientNode = null): array
238238
$result['share_with'] = $share->getSharedWith();
239239
$result['share_with_displayname'] = $sharedWith !== null ? $sharedWith->getDisplayName() : $share->getSharedWith();
240240
$result['share_with_displayname_unique'] = $sharedWith !== null ? (
241-
$sharedWith->getEMailAddress() !== '' ? $sharedWith->getEMailAddress() : $sharedWith->getUID()
241+
!empty($sharedWith->getSystemEMailAddress()) ? $sharedWith->getSystemEMailAddress() : $sharedWith->getUID()
242242
) : $share->getSharedWith();
243243
$result['status'] = [];
244244

apps/files_sharing/tests/Controller/ShareAPIControllerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
use OCP\Files\NotFoundException;
4848
use OCP\Files\Storage;
4949
use OCP\IConfig;
50+
use OCP\IGroup;
5051
use OCP\IGroupManager;
5152
use OCP\IL10N;
5253
use OCP\IPreview;
@@ -785,7 +786,7 @@ public function testGetShare(\OCP\Share\IShare $share, array $result) {
785786
$user = $this->getMockBuilder(IUser::class)->getMock();
786787
$user->method('getUID')->willReturn('userId');
787788
$user->method('getDisplayName')->willReturn('userDisplay');
788-
$user->method('getEMailAddress')->willReturn('userId@example.com');
789+
$user->method('getSystemEMailAddress')->willReturn('userId@example.com');
789790

790791
$group = $this->getMockBuilder('OCP\IGroup')->getMock();
791792
$group->method('getGID')->willReturn('groupId');
@@ -3586,7 +3587,7 @@ public function dataFormatShare() {
35863587
$initiator->method('getDisplayName')->willReturn('initiatorDN');
35873588
$recipient = $this->getMockBuilder(IUser::class)->getMock();
35883589
$recipient->method('getDisplayName')->willReturn('recipientDN');
3589-
$recipient->method('getEmailAddress')->willReturn('recipient');
3590+
$recipient->method('getSystemEMailAddress')->willReturn('recipient');
35903591

35913592

35923593
$result = [];
@@ -4387,7 +4388,7 @@ public function dataFormatShare() {
43874388
public function testFormatShare(array $expects, \OCP\Share\IShare $share, array $users, $exception) {
43884389
$this->userManager->method('get')->willReturnMap($users);
43894390

4390-
$recipientGroup = $this->createMock('\OCP\IGroup');
4391+
$recipientGroup = $this->createMock(IGroup::class);
43914392
$recipientGroup->method('getDisplayName')->willReturn('recipientGroupDisplayName');
43924393
$this->groupManager->method('get')->willReturnMap([
43934394
['recipientGroup', $recipientGroup],
@@ -4397,7 +4398,6 @@ public function testFormatShare(array $expects, \OCP\Share\IShare $share, array
43974398
->with('files_sharing.sharecontroller.showShare', ['token' => 'myToken'])
43984399
->willReturn('myLink');
43994400

4400-
44014401
$this->rootFolder->method('getUserFolder')
44024402
->with($this->currentUser)
44034403
->willReturnSelf();

apps/provisioning_api/appinfo/routes.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,9 @@
7474
['name' => 'AppConfig#setValue', 'url' => '/api/v1/config/apps/{app}/{key}', 'verb' => 'POST'],
7575
['name' => 'AppConfig#deleteKey', 'url' => '/api/v1/config/apps/{app}/{key}', 'verb' => 'DELETE'],
7676
],
77+
'routes' => [
78+
// Verification
79+
['name' => 'Verification#showVerifyMail', 'url' => '/mailVerification/{key}/{token}/{userId}', 'verb' => 'GET'],
80+
['name' => 'Verification#verifyMail', 'url' => '/mailVerification/{key}/{token}/{userId}', 'verb' => 'POST'],
81+
]
7782
];

apps/provisioning_api/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
'OCA\\Provisioning_API\\Controller\\AppsController' => $baseDir . '/../lib/Controller/AppsController.php',
1515
'OCA\\Provisioning_API\\Controller\\GroupsController' => $baseDir . '/../lib/Controller/GroupsController.php',
1616
'OCA\\Provisioning_API\\Controller\\UsersController' => $baseDir . '/../lib/Controller/UsersController.php',
17+
'OCA\\Provisioning_API\\Controller\\VerificationController' => $baseDir . '/../lib/Controller/VerificationController.php',
1718
'OCA\\Provisioning_API\\FederatedShareProviderFactory' => $baseDir . '/../lib/FederatedShareProviderFactory.php',
1819
'OCA\\Provisioning_API\\Listener\\UserDeletedListener' => $baseDir . '/../lib/Listener/UserDeletedListener.php',
1920
'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => $baseDir . '/../lib/Middleware/Exceptions/NotSubAdminException.php',

apps/provisioning_api/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ComposerStaticInitProvisioning_API
2929
'OCA\\Provisioning_API\\Controller\\AppsController' => __DIR__ . '/..' . '/../lib/Controller/AppsController.php',
3030
'OCA\\Provisioning_API\\Controller\\GroupsController' => __DIR__ . '/..' . '/../lib/Controller/GroupsController.php',
3131
'OCA\\Provisioning_API\\Controller\\UsersController' => __DIR__ . '/..' . '/../lib/Controller/UsersController.php',
32+
'OCA\\Provisioning_API\\Controller\\VerificationController' => __DIR__ . '/..' . '/../lib/Controller/VerificationController.php',
3233
'OCA\\Provisioning_API\\FederatedShareProviderFactory' => __DIR__ . '/..' . '/../lib/FederatedShareProviderFactory.php',
3334
'OCA\\Provisioning_API\\Listener\\UserDeletedListener' => __DIR__ . '/..' . '/../lib/Listener/UserDeletedListener.php',
3435
'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => __DIR__ . '/..' . '/../lib/Middleware/Exceptions/NotSubAdminException.php',

apps/provisioning_api/composer/composer/installed.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
'type' => 'library',
66
'install_path' => __DIR__ . '/../',
77
'aliases' => array(),
8-
'reference' => 'fa56c13484afa1baf908b93ed5b6990c6a0e9ad6',
8+
'reference' => '2e49000abb5acb09de041369a2239db23fa63ec7',
99
'name' => '__root__',
1010
'dev' => false,
1111
),
@@ -16,7 +16,7 @@
1616
'type' => 'library',
1717
'install_path' => __DIR__ . '/../',
1818
'aliases' => array(),
19-
'reference' => 'fa56c13484afa1baf908b93ed5b6990c6a0e9ad6',
19+
'reference' => '2e49000abb5acb09de041369a2239db23fa63ec7',
2020
'dev_requirement' => false,
2121
),
2222
),

apps/provisioning_api/lib/Controller/AUserData.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@
5454
abstract class AUserData extends OCSController {
5555
public const SCOPE_SUFFIX = 'Scope';
5656

57+
public const USER_FIELD_DISPLAYNAME = 'display';
58+
public const USER_FIELD_LANGUAGE = 'language';
59+
public const USER_FIELD_LOCALE = 'locale';
60+
public const USER_FIELD_PASSWORD = 'password';
61+
public const USER_FIELD_QUOTA = 'quota';
62+
public const USER_FIELD_NOTIFICATION_EMAIL = 'notify_email';
63+
5764
/** @var IUserManager */
5865
protected $userManager;
5966
/** @var IConfig */
@@ -139,14 +146,14 @@ protected function getUserData(string $userId, bool $includeScopes = false): arr
139146
$data['lastLogin'] = $targetUserObject->getLastLogin() * 1000;
140147
$data['backend'] = $targetUserObject->getBackendClassName();
141148
$data['subadmin'] = $this->getUserSubAdminGroupsData($targetUserObject->getUID());
142-
$data['quota'] = $this->fillStorageInfo($targetUserObject->getUID());
149+
$data[self::USER_FIELD_QUOTA] = $this->fillStorageInfo($targetUserObject->getUID());
143150

144151
try {
145152
if ($includeScopes) {
146153
$data[IAccountManager::PROPERTY_AVATAR . self::SCOPE_SUFFIX] = $userAccount->getProperty(IAccountManager::PROPERTY_AVATAR)->getScope();
147154
}
148155

149-
$data[IAccountManager::PROPERTY_EMAIL] = $targetUserObject->getEMailAddress();
156+
$data[IAccountManager::PROPERTY_EMAIL] = $targetUserObject->getSystemEMailAddress();
150157
if ($includeScopes) {
151158
$data[IAccountManager::PROPERTY_EMAIL . self::SCOPE_SUFFIX] = $userAccount->getProperty(IAccountManager::PROPERTY_EMAIL)->getScope();
152159
}
@@ -187,8 +194,9 @@ protected function getUserData(string $userId, bool $includeScopes = false): arr
187194
}
188195

189196
$data['groups'] = $gids;
190-
$data['language'] = $this->l10nFactory->getUserLanguage($targetUserObject);
191-
$data['locale'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'locale');
197+
$data[self::USER_FIELD_LANGUAGE] = $this->l10nFactory->getUserLanguage($targetUserObject);
198+
$data[self::USER_FIELD_LOCALE] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'locale');
199+
$data[self::USER_FIELD_NOTIFICATION_EMAIL] = $targetUserObject->getPrimaryEMailAddress();
192200

193201
$backend = $targetUserObject->getBackend();
194202
$data['backendCapabilities'] = [
@@ -238,7 +246,7 @@ protected function fillStorageInfo(string $userId): array {
238246
'used' => $storage['used'],
239247
'total' => $storage['total'],
240248
'relative' => $storage['relative'],
241-
'quota' => $storage['quota'],
249+
self::USER_FIELD_QUOTA => $storage['quota'],
242250
];
243251
} catch (NotFoundException $ex) {
244252
// User fs is not setup yet
@@ -251,7 +259,7 @@ protected function fillStorageInfo(string $userId): array {
251259
$quota = OC_Helper::computerFileSize($quota);
252260
}
253261
$data = [
254-
'quota' => $quota !== false ? $quota : 'none',
262+
self::USER_FIELD_QUOTA => $quota !== false ? $quota : 'none',
255263
'used' => 0
256264
];
257265
}

0 commit comments

Comments
 (0)