Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-08-19 00:52:34 +0300
committerJoas Schilling <coding@schilljs.com>2022-08-19 11:48:32 +0300
commit7e1177819023a185480b5251e3a22dc429948518 (patch)
tree66288b17692cfcdde3e3273051e00224b4167b1f /apps/settings/lib
parentcab0f1327e28104ef61e8767f963d20cf38544af (diff)
Use user name cache in activity providers
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/settings/lib')
-rw-r--r--apps/settings/lib/Activity/GroupProvider.php25
-rw-r--r--apps/settings/lib/Activity/Provider.php18
2 files changed, 2 insertions, 41 deletions
diff --git a/apps/settings/lib/Activity/GroupProvider.php b/apps/settings/lib/Activity/GroupProvider.php
index a1709de5c3f..466bb9abeee 100644
--- a/apps/settings/lib/Activity/GroupProvider.php
+++ b/apps/settings/lib/Activity/GroupProvider.php
@@ -51,8 +51,6 @@ class GroupProvider implements IProvider {
/** @var string[] */
protected $groupDisplayNames = [];
- /** @var string[] */
- protected $userDisplayNames = [];
public function __construct(L10nFactory $l10n,
@@ -169,32 +167,11 @@ class GroupProvider implements IProvider {
return $gid;
}
- /**
- * @param string $uid
- * @return array
- */
protected function generateUserParameter(string $uid): array {
- if (!isset($this->displayNames[$uid])) {
- $this->userDisplayNames[$uid] = $this->getDisplayName($uid);
- }
-
return [
'type' => 'user',
'id' => $uid,
- 'name' => $this->userDisplayNames[$uid],
+ 'name' => $this->userManager->getDisplayName($uid) ?? $uid,
];
}
-
- /**
- * @param string $uid
- * @return string
- */
- protected function getDisplayName(string $uid): string {
- $user = $this->userManager->get($uid);
- if ($user instanceof IUser) {
- return $user->getDisplayName();
- } else {
- return $uid;
- }
- }
}
diff --git a/apps/settings/lib/Activity/Provider.php b/apps/settings/lib/Activity/Provider.php
index a6314fdfb11..7d8a7f0da9a 100644
--- a/apps/settings/lib/Activity/Provider.php
+++ b/apps/settings/lib/Activity/Provider.php
@@ -66,9 +66,6 @@ class Provider implements IProvider {
/** @var IManager */
private $activityManager;
- /** @var string[] cached displayNames - key is the UID and value the displayname */
- protected $displayNames = [];
-
public function __construct(IFactory $languageFactory,
IURLGenerator $url,
IUserManager $userManager,
@@ -206,23 +203,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;
- }
}