From 7e1177819023a185480b5251e3a22dc429948518 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 18 Aug 2022 23:52:34 +0200 Subject: Use user name cache in activity providers Signed-off-by: Joas Schilling --- apps/comments/lib/Activity/Provider.php | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'apps/comments') 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; - } } -- cgit v1.2.3