diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2022-08-19 12:28:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-19 12:28:44 +0200 |
commit | 71065f5fd5f75b5847795eb0df916c12a7dfc07d (patch) | |
tree | 8c226708224f0d07121baec337fa898fc9e71ee5 /apps/files | |
parent | 7d7f7abf7fb3f7ea8e5382a101b8246021de0bbf (diff) | |
parent | 7e1177819023a185480b5251e3a22dc429948518 (diff) | |
download | nextcloud-server-71065f5fd5f75b5847795eb0df916c12a7dfc07d.tar.gz nextcloud-server-71065f5fd5f75b5847795eb0df916c12a7dfc07d.zip |
Merge pull request #33615 from nextcloud/perf/noid/user-displayname-cache-for-activity-providers
Use user name cache in activity providers
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/lib/Activity/Provider.php | 8 | ||||
-rw-r--r-- | apps/files/tests/Activity/ProviderTest.php | 11 |
2 files changed, 6 insertions, 13 deletions
diff --git a/apps/files/lib/Activity/Provider.php b/apps/files/lib/Activity/Provider.php index a7db85a0de1..c21e8f9ad16 100644 --- a/apps/files/lib/Activity/Provider.php +++ b/apps/files/lib/Activity/Provider.php @@ -527,12 +527,12 @@ class Provider implements IProvider { */ protected function getUser($uid) { // First try local user - $user = $this->userManager->get($uid); - if ($user instanceof IUser) { + $displayName = $this->userManager->getDisplayName($uid); + if ($displayName !== null) { return [ 'type' => 'user', - 'id' => $user->getUID(), - 'name' => $user->getDisplayName(), + 'id' => $uid, + 'name' => $displayName, ]; } diff --git a/apps/files/tests/Activity/ProviderTest.php b/apps/files/tests/Activity/ProviderTest.php index 7c5bdf27ba1..3566d83f415 100644 --- a/apps/files/tests/Activity/ProviderTest.php +++ b/apps/files/tests/Activity/ProviderTest.php @@ -177,17 +177,10 @@ class ProviderTest extends TestCase { $provider = $this->getProvider(); if ($userDisplayName !== null) { - $user = $this->createMock(IUser::class); - $user->expects($this->once()) - ->method('getUID') - ->willReturn($uid); - $user->expects($this->once()) - ->method('getDisplayName') - ->willReturn($userDisplayName); $this->userManager->expects($this->once()) - ->method('get') + ->method('getDisplayName') ->with($uid) - ->willReturn($user); + ->willReturn($userDisplayName); } if ($cloudIdData !== null) { $this->cloudIdManager->expects($this->once()) |