diff options
author | Joas Schilling <coding@schilljs.com> | 2022-08-18 23:52:34 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-08-19 10:48:32 +0200 |
commit | 7e1177819023a185480b5251e3a22dc429948518 (patch) | |
tree | 66288b17692cfcdde3e3273051e00224b4167b1f /apps/dav/lib | |
parent | cab0f1327e28104ef61e8767f963d20cf38544af (diff) | |
download | nextcloud-server-7e1177819023a185480b5251e3a22dc429948518.tar.gz nextcloud-server-7e1177819023a185480b5251e3a22dc429948518.zip |
Use user name cache in activity providers
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r-- | apps/dav/lib/CalDAV/Activity/Provider/Base.php | 24 | ||||
-rw-r--r-- | apps/dav/lib/CardDAV/Activity/Provider/Base.php | 22 |
2 files changed, 3 insertions, 43 deletions
diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Base.php b/apps/dav/lib/CalDAV/Activity/Provider/Base.php index 7f70980a72b..48ed7b8b107 100644 --- a/apps/dav/lib/CalDAV/Activity/Provider/Base.php +++ b/apps/dav/lib/CalDAV/Activity/Provider/Base.php @@ -112,35 +112,15 @@ abstract class Base implements IProvider { ]; } - /** - * @param string $uid - * @return array - */ - protected function generateUserParameter($uid) { - if (!isset($this->userDisplayNames[$uid])) { - $this->userDisplayNames[$uid] = $this->getUserDisplayName($uid); - } - + protected function generateUserParameter(string $uid): array { return [ 'type' => 'user', 'id' => $uid, - 'name' => $this->userDisplayNames[$uid], + 'name' => $this->userManager->getDisplayName($uid) ?? $uid, ]; } /** - * @param string $uid - * @return string - */ - protected function getUserDisplayName($uid) { - $user = $this->userManager->get($uid); - if ($user instanceof IUser) { - return $user->getDisplayName(); - } - return $uid; - } - - /** * @param string $gid * @return array */ diff --git a/apps/dav/lib/CardDAV/Activity/Provider/Base.php b/apps/dav/lib/CardDAV/Activity/Provider/Base.php index 2f6de31de15..3e7a966c08a 100644 --- a/apps/dav/lib/CardDAV/Activity/Provider/Base.php +++ b/apps/dav/lib/CardDAV/Activity/Provider/Base.php @@ -98,35 +98,15 @@ abstract class Base implements IProvider { ]; } - /** - * @param string $uid - * @return array - */ protected function generateUserParameter(string $uid): array { - if (!isset($this->userDisplayNames[$uid])) { - $this->userDisplayNames[$uid] = $this->getUserDisplayName($uid); - } - return [ 'type' => 'user', 'id' => $uid, - 'name' => $this->userDisplayNames[$uid], + 'name' => $this->userManager->getDisplayName($uid) ?? $uid, ]; } /** - * @param string $uid - * @return string - */ - protected function getUserDisplayName(string $uid): string { - $user = $this->userManager->get($uid); - if ($user instanceof IUser) { - return $user->getDisplayName(); - } - return $uid; - } - - /** * @param string $gid * @return array */ |