diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-06-07 13:04:56 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-06-07 13:04:56 +0300 |
commit | 3f5169c9c263fc41028f91ce9a73df3e35bc5899 (patch) | |
tree | 29835155345eb7b79bccaac5310856a06832f7ac /lib/Service/SessionService.php | |
parent | efc373373d0e577f9d1dd605abfb142a13ef69d3 (diff) |
Implement guestName for public shares
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/Service/SessionService.php')
-rw-r--r-- | lib/Service/SessionService.php | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Service/SessionService.php b/lib/Service/SessionService.php index a23447914..9de0ea0a9 100644 --- a/lib/Service/SessionService.php +++ b/lib/Service/SessionService.php @@ -46,20 +46,21 @@ class SessionService { $this->sessionMapper = $sessionMapper; $this->secureRandom = $secureRandom; $this->timeFactory = $timeFactory; - $this->userId = $userId ?? 'Guest'; + $this->userId = $userId; } - public function initSession($documentId): Session { + public function initSession($documentId, $guestName = null): Session { $session = new Session(); $session->setDocumentId($documentId); - $session->setUserId($this->userId); + $userName = $this->userId ? $this->userId : $guestName; + $session->setUserId($userName); $session->setToken($this->secureRandom->generate(64)); /** @var IAvatarManager $avatarGenerator */ $avatarGenerator = \OC::$server->query(IAvatarManager::class); - $color = $avatarGenerator->getGuestAvatar($this->userId)->avatarBackgroundColor($this->userId); + $color = $avatarGenerator->getGuestAvatar($userName)->avatarBackgroundColor($userName); $color = sprintf("#%02x%02x%02x", $color->r, $color->g, $color->b); $session->setColor($color); - $session->setGuestName(null); + $session->setGuestName($guestName); $session->setLastContact($this->timeFactory->getTime()); return $this->sessionMapper->insert($session); } |