mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
fix: Add UserProviderInterface dependency.
This commit is contained in:
parent
7053b3fdff
commit
d1ce6a668c
@ -19,6 +19,7 @@ use Psr\Http\Client\ClientInterface;
|
|||||||
use Psr\Http\Message\RequestInterface;
|
use Psr\Http\Message\RequestInterface;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||||
|
|
||||||
final class ChillWopi implements WopiInterface
|
final class ChillWopi implements WopiInterface
|
||||||
{
|
{
|
||||||
@ -34,13 +35,16 @@ final class ChillWopi implements WopiInterface
|
|||||||
|
|
||||||
private Security $security;
|
private Security $security;
|
||||||
|
|
||||||
|
private UserProviderInterface $userProvider;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Psr17Interface $psr17,
|
Psr17Interface $psr17,
|
||||||
WopiDiscoveryInterface $wopiDiscovery,
|
WopiDiscoveryInterface $wopiDiscovery,
|
||||||
StoredObjectRepository $storedObjectRepository,
|
StoredObjectRepository $storedObjectRepository,
|
||||||
ClientInterface $httpClient,
|
ClientInterface $httpClient,
|
||||||
TempUrlGeneratorInterface $tempUrlGeneratorInterface,
|
TempUrlGeneratorInterface $tempUrlGeneratorInterface,
|
||||||
Security $security
|
Security $security,
|
||||||
|
UserProviderInterface $userProvider
|
||||||
) {
|
) {
|
||||||
$this->psr17 = $psr17;
|
$this->psr17 = $psr17;
|
||||||
$this->wopiDiscovery = $wopiDiscovery;
|
$this->wopiDiscovery = $wopiDiscovery;
|
||||||
@ -48,6 +52,7 @@ final class ChillWopi implements WopiInterface
|
|||||||
$this->httpClient = $httpClient;
|
$this->httpClient = $httpClient;
|
||||||
$this->tempUrlGeneratorInterface = $tempUrlGeneratorInterface;
|
$this->tempUrlGeneratorInterface = $tempUrlGeneratorInterface;
|
||||||
$this->security = $security;
|
$this->security = $security;
|
||||||
|
$this->userProvider = $userProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkFileInfo(
|
public function checkFileInfo(
|
||||||
@ -55,6 +60,8 @@ final class ChillWopi implements WopiInterface
|
|||||||
?string $accessToken,
|
?string $accessToken,
|
||||||
RequestInterface $request
|
RequestInterface $request
|
||||||
): ResponseInterface {
|
): ResponseInterface {
|
||||||
|
$user = $this->userProvider->loadUserByUsername($accessToken);
|
||||||
|
|
||||||
$storedObject = $this->storedObjectRepository->findOneBy(['filename' => $fileId]);
|
$storedObject = $this->storedObjectRepository->findOneBy(['filename' => $fileId]);
|
||||||
|
|
||||||
if (null === $storedObject) {
|
if (null === $storedObject) {
|
||||||
@ -74,15 +81,15 @@ final class ChillWopi implements WopiInterface
|
|||||||
->withBody($this->psr17->createStream((string) json_encode(
|
->withBody($this->psr17->createStream((string) json_encode(
|
||||||
[
|
[
|
||||||
'BaseFileName' => $storedObject->getFilename(),
|
'BaseFileName' => $storedObject->getFilename(),
|
||||||
'OwnerId' => $this->security->getUser()->getUsername(),
|
'OwnerId' => $user->getUsername(),
|
||||||
'Size' => 0,
|
'Size' => 0,
|
||||||
'UserId' => $this->security->getUser()->getUsername(),
|
'UserId' => $user->getUsername(),
|
||||||
// 'Version' => 'v' . uniqid(),
|
// 'Version' => 'v' . uniqid(),
|
||||||
'ReadOnly' => false,
|
'ReadOnly' => false,
|
||||||
'UserCanWrite' => true,
|
'UserCanWrite' => true,
|
||||||
'UserCanNotWriteRelative' => false,
|
'UserCanNotWriteRelative' => false,
|
||||||
'SupportsLocks' => true,
|
'SupportsLocks' => true,
|
||||||
'UserFriendlyName' => sprintf('User %s', $this->security->getUser()->getUsername()),
|
'UserFriendlyName' => sprintf('User %s', $user->getUsername()),
|
||||||
'UserExtraInfo' => [],
|
'UserExtraInfo' => [],
|
||||||
'LastModifiedTime' => date('Y-m-d\TH:i:s.u\Z', $storedObject->getCreationDate()->getTimestamp()),
|
'LastModifiedTime' => date('Y-m-d\TH:i:s.u\Z', $storedObject->getCreationDate()->getTimestamp()),
|
||||||
'CloseButtonClosesWindow' => true,
|
'CloseButtonClosesWindow' => true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user