fix: Add user data.

This commit is contained in:
Pol Dellaiera 2021-08-17 17:20:02 +02:00 committed by Marc Ducobu
parent f7fabdbf1c
commit c1e2fd64ff

View File

@ -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,