Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Do not try to get a displayname for guests
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr authored and max-nextcloud committed Aug 31, 2022
commit 3f6f5d1e0391eadb309543375d9a42c22bbf70ae
4 changes: 2 additions & 2 deletions lib/Controller/ImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ public function getImage(int $documentId, int $sessionId, string $sessionToken,
* @param int $documentId
* @param int $sessionId
* @param string $sessionToken
* @return string
* @return ?string
*/
private function getUserIdFromSession(int $documentId, int $sessionId, string $sessionToken): string {
private function getUserIdFromSession(int $documentId, int $sessionId, string $sessionToken): ?string {
$session = $this->sessionService->getSession($documentId, $sessionId, $sessionToken);
return $session->getUserId();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
use OCP\AppFramework\Db\Entity;

/**
* @method string getUserId()
* @method ?string getUserId()
* @method void setUserId(?string $userId)
* @method string getToken()
* @method void setToken(string $token)
Expand Down
8 changes: 6 additions & 2 deletions lib/Service/SessionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ public function getAllSessions($documentId): array {
$sessions = $this->sessionMapper->findAll($documentId);
return array_map(function (Session $session) {
$result = $session->jsonSerialize();
$result['displayName'] = $this->userManager->getDisplayName($session->getUserId());
if ($session->getUserId() !== null) {
$result['displayName'] = $this->userManager->getDisplayName($session->getUserId());
}
return $result;
}, $sessions);
}
Expand All @@ -125,7 +127,9 @@ public function getActiveSessions($documentId): array {
$sessions = $this->sessionMapper->findAllActive($documentId);
return array_map(function (Session $session) {
$result = $session->jsonSerialize();
$result['displayName'] = $this->userManager->getDisplayName($session->getUserId());
if ($session->getUserId() !== null) {
$result['displayName'] = $this->userManager->getDisplayName($session->getUserId());
}
return $result;
}, $sessions);
}
Expand Down