From a1537b8748bdedebd06216a5e4ebdc908e37d96d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 8 May 2024 20:09:21 +0200 Subject: [PATCH] fix: Bring back actually setting the guest name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Controller/DocumentController.php | 2 ++ lib/TokenManager.php | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/Controller/DocumentController.php b/lib/Controller/DocumentController.php index ca75ad1df3..b31b654a55 100644 --- a/lib/Controller/DocumentController.php +++ b/lib/Controller/DocumentController.php @@ -383,6 +383,8 @@ public function token(int $fileId, ?string $shareToken = null, ?string $path = n $wopi = $this->getToken($file, $share); + $this->tokenManager->setGuestName($wopi, $guestName); + return new DataResponse(array_merge( [ 'urlSrc' => $this->tokenManager->getUrlSrc($file) ], $wopi->jsonSerialize(), diff --git a/lib/TokenManager.php b/lib/TokenManager.php index 4621e9ec3f..83593fe169 100644 --- a/lib/TokenManager.php +++ b/lib/TokenManager.php @@ -313,6 +313,15 @@ public function updateGuestName(string $accessToken, string $guestName) { $this->wopiMapper->update($wopi); } + public function setGuestName(Wopi $wopi, ?string $guestName = null): Wopi { + if ($wopi->getTokenType() !== Wopi::TOKEN_TYPE_GUEST && $wopi->getTokenType() !== Wopi::TOKEN_TYPE_REMOTE_GUEST) { + return $wopi; + } + + $wopi->setGuestDisplayname($this->prepareGuestName($guestName)); + return $this->wopiMapper->update($wopi); + } + public function getUrlSrc(File $file): string { return $this->wopiParser->getUrlSrcValue($file->getMimeType()); }