diff options
author | Julius Härtl <jus@bitgrid.net> | 2022-08-16 16:27:20 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2022-08-17 13:13:09 +0300 |
commit | d0d85624c04086c9c866f70f30599b40ad51ca3d (patch) | |
tree | b1382deecaf5e24d3e1c827eb86ff49c81a469c5 /lib | |
parent | 48b21b6e524c4aef78a1046e1f19a2bbd85837c4 (diff) |
Use displayname cache for fetching session dataenh/noid/displayname-cache
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Service/SessionService.php | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/lib/Service/SessionService.php b/lib/Service/SessionService.php index 845d4dd5e..7a9729669 100644 --- a/lib/Service/SessionService.php +++ b/lib/Service/SessionService.php @@ -32,22 +32,17 @@ use OCP\IAvatarManager; use OCP\ICache; use OCP\ICacheFactory; use OCP\IRequest; +use OCP\IUserManager; use OCP\Security\ISecureRandom; class SessionService { public const SESSION_VALID_TIME = 5 * 60; - /** @var SessionMapper */ - private $sessionMapper; - - /** @var ISecureRandom */ - private $secureRandom; - - /** @var ITimeFactory */ - private $timeFactory; - - /** @var IAvatarManager */ - private $avatarManager; + private SessionMapper $sessionMapper; + private ISecureRandom $secureRandom; + private ITimeFactory $timeFactory; + private IUserManager $userManager; + private IAvatarManager $avatarManager; /** @var string|null */ private $userId; @@ -62,6 +57,7 @@ class SessionService { SessionMapper $sessionMapper, ISecureRandom $secureRandom, ITimeFactory $timeFactory, + IUserManager $userManager, IAvatarManager $avatarManager, IRequest $request, IManager $directManager, @@ -71,6 +67,7 @@ class SessionService { $this->sessionMapper = $sessionMapper; $this->secureRandom = $secureRandom; $this->timeFactory = $timeFactory; + $this->userManager = $userManager; $this->avatarManager = $avatarManager; $this->userId = $userId; @@ -119,11 +116,7 @@ class SessionService { $sessions = $this->sessionMapper->findAll($documentId); return array_map(function (Session $session) { $result = $session->jsonSerialize(); - $userManager = \OC::$server->getUserManager(); - $user = $userManager->get($session->getUserId()); - if ($user) { - $result['displayName'] = $user->getDisplayName(); - } + $result['displayName'] = $this->userManager->getDisplayName($session->getUserId()); return $result; }, $sessions); } @@ -132,11 +125,7 @@ class SessionService { $sessions = $this->sessionMapper->findAllActive($documentId); return array_map(function (Session $session) { $result = $session->jsonSerialize(); - $userManager = \OC::$server->getUserManager(); - $user = $userManager->get($session->getUserId()); - if ($user) { - $result['displayName'] = $user->getDisplayName(); - } + $result['displayName'] = $this->userManager->getDisplayName($session->getUserId()); return $result; }, $sessions); } |