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

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2019-06-15 00:26:12 +0300
committerJulius Härtl <jus@bitgrid.net>2019-06-15 11:14:01 +0300
commitd392585407cfd5abfd6b9f1880c96feeacc5447a (patch)
tree2ea57b1a86aeac4e07d3a0630fdaa99db0432dc8 /lib/Service/SessionService.php
parent1428971a593764d829007b30ffe9d13d3ffec8ab (diff)
Implement guest name change
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/Service/SessionService.php')
-rw-r--r--lib/Service/SessionService.php22
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/Service/SessionService.php b/lib/Service/SessionService.php
index fe796955c..b4eb393dd 100644
--- a/lib/Service/SessionService.php
+++ b/lib/Service/SessionService.php
@@ -60,7 +60,9 @@ class SessionService {
$color = $avatarGenerator->getGuestAvatar($userName)->avatarBackgroundColor($userName);
$color = sprintf("#%02x%02x%02x", $color->r, $color->g, $color->b);
$session->setColor($color);
- $session->setGuestName($guestName);
+ if ($this->userId === null) {
+ $session->setGuestName($guestName);
+ }
$session->setLastContact($this->timeFactory->getTime());
return $this->sessionMapper->insert($session);
}
@@ -102,8 +104,20 @@ class SessionService {
return true;
}
- public function cleanupSession() {
- // find expired sessions
- // remove them
+ /**
+ * @param $documentId
+ * @param $sessionId
+ * @param $sessionToken
+ * @param $guestName
+ * @return Session
+ * @throws DoesNotExistException
+ */
+ public function updateSession(int $documentId, int $sessionId, string $sessionToken, string $guestName): Session {
+ if ($this->userId !== null) {
+ throw new \Exception('Logged in users cannot set a guest name');
+ }
+ $session = $this->sessionMapper->find($documentId, $sessionId, $sessionToken);
+ $session->setGuestName($guestName);
+ return $this->sessionMapper->update($session);
}
}