summaryrefslogtreecommitdiffstats
path: root/apps/comments
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2022-08-19 12:28:44 +0200
committerGitHub <noreply@github.com>2022-08-19 12:28:44 +0200
commit71065f5fd5f75b5847795eb0df916c12a7dfc07d (patch)
tree8c226708224f0d07121baec337fa898fc9e71ee5 /apps/comments
parent7d7f7abf7fb3f7ea8e5382a101b8246021de0bbf (diff)
parent7e1177819023a185480b5251e3a22dc429948518 (diff)
downloadnextcloud-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/comments')
-rw-r--r--apps/comments/lib/Activity/Provider.php16
1 files changed, 1 insertions, 15 deletions
diff --git a/apps/comments/lib/Activity/Provider.php b/apps/comments/lib/Activity/Provider.php
index 715be29e2ed..c6e55326580 100644
--- a/apps/comments/lib/Activity/Provider.php
+++ b/apps/comments/lib/Activity/Provider.php
@@ -43,8 +43,6 @@ class Provider implements IProvider {
protected ICommentsManager $commentsManager;
protected IUserManager $userManager;
protected IManager $activityManager;
- /** @var string[] */
- protected array $displayNames = [];
public function __construct(IFactory $languageFactory, IURLGenerator $url, ICommentsManager $commentsManager, IUserManager $userManager, IManager $activityManager) {
$this->languageFactory = $languageFactory;
@@ -213,22 +211,10 @@ class Provider implements IProvider {
}
protected function generateUserParameter(string $uid): array {
- if (!isset($this->displayNames[$uid])) {
- $this->displayNames[$uid] = $this->getDisplayName($uid);
- }
-
return [
'type' => 'user',
'id' => $uid,
- 'name' => $this->displayNames[$uid],
+ 'name' => $this->userManager->getDisplayName($uid) ?? $uid,
];
}
-
- protected function getDisplayName(string $uid): string {
- $user = $this->userManager->get($uid);
- if ($user instanceof IUser) {
- return $user->getDisplayName();
- }
- return $uid;
- }
}