Skip to content

Commit

Permalink
Merge pull request #3683 from nextcloud/backport/3681/stable28
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusknorr authored May 8, 2024
2 parents bb4e6cc + fa2784d commit c3c1a50
Show file tree
Hide file tree
Showing 6 changed files with 442 additions and 680 deletions.
2 changes: 2 additions & 0 deletions lib/Controller/DocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
9 changes: 9 additions & 0 deletions lib/TokenManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Loading

0 comments on commit c3c1a50

Please sign in to comment.