diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillWopi.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillWopi.php index 54bfce885..713e1a197 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillWopi.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillWopi.php @@ -18,6 +18,7 @@ use loophp\psr17\Psr17Interface; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; +use Symfony\Component\Security\Core\Security; final class ChillWopi implements WopiInterface { @@ -31,18 +32,22 @@ final class ChillWopi implements WopiInterface private TempUrlGeneratorInterface $tempUrlGeneratorInterface; + private Security $security; + public function __construct( Psr17Interface $psr17, WopiDiscoveryInterface $wopiDiscovery, StoredObjectRepository $storedObjectRepository, ClientInterface $httpClient, - TempUrlGeneratorInterface $tempUrlGeneratorInterface + TempUrlGeneratorInterface $tempUrlGeneratorInterface, + Security $security ) { $this->psr17 = $psr17; $this->wopiDiscovery = $wopiDiscovery; $this->storedObjectRepository = $storedObjectRepository; $this->httpClient = $httpClient; $this->tempUrlGeneratorInterface = $tempUrlGeneratorInterface; + $this->security = $security; } public function checkFileInfo( @@ -69,15 +74,15 @@ final class ChillWopi implements WopiInterface ->withBody($this->psr17->createStream((string) json_encode( [ 'BaseFileName' => $storedObject->getFilename(), - 'OwnerId' => uniqid(), + 'OwnerId' => $this->security->getUser()->getUsername(), 'Size' => 0, - 'UserId' => uniqid(), - 'Version' => 'v' . uniqid(), + 'UserId' => $this->security->getUser()->getUsername(), +// 'Version' => 'v' . uniqid(), 'ReadOnly' => false, 'UserCanWrite' => true, 'UserCanNotWriteRelative' => false, 'SupportsLocks' => true, - 'UserFriendlyName' => 'User Name ' . uniqid(), + 'UserFriendlyName' => sprintf('User %s', $this->security->getUser()->getUsername()), 'UserExtraInfo' => [], 'LastModifiedTime' => date('Y-m-d\TH:i:s.u\Z', $storedObject->getCreationDate()->getTimestamp()), 'CloseButtonClosesWindow' => true,