diff options
author | Julius Härtl <jus@bitgrid.net> | 2022-04-21 13:33:56 +0300 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2022-04-21 19:09:00 +0300 |
commit | 56357a26b2682183086b6ca6dbe541b7de87810e (patch) | |
tree | 7088af9f53c75d26aa1e09a465f84dad4ad3c2bf /lib | |
parent | 15e613d913e28208715342a4d4838878c86a46e8 (diff) |
Open files read only if locked
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Service/ApiService.php | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/Service/ApiService.php b/lib/Service/ApiService.php index 850c72c74..69712cfbe 100644 --- a/lib/Service/ApiService.php +++ b/lib/Service/ApiService.php @@ -28,6 +28,7 @@ namespace OCA\Text\Service; use Exception; use OC\Files\Node\File; +use OCA\Text\AppInfo\Application; use OCA\Text\DocumentHasUnsavedChangesException; use OCA\Text\DocumentSaveConflictException; use OCA\Text\VersionMismatchException; @@ -37,6 +38,7 @@ use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\FileDisplayResponse; use OCP\AppFramework\Http\NotFoundResponse; use OCP\Constants; +use OCP\Files\Lock\ILock; use OCP\Files\NotFoundException; use OCP\ILogger; use OCP\IRequest; @@ -63,7 +65,6 @@ class ApiService { public function create($fileId = null, $filePath = null, $token = null, $guestName = null, bool $forceRecreate = false): DataResponse { try { - $readOnly = true; /** @var File $file */ if ($token) { $file = $this->documentService->getFileByShareToken($token, $this->request->getParam('filePath')); @@ -77,19 +78,14 @@ class ApiService { } catch (NotFoundException $e) { return new DataResponse([], Http::STATUS_NOT_FOUND); } - - try { - $this->documentService->checkSharePermissions($token, Constants::PERMISSION_UPDATE); - $readOnly = false; - } catch (NotFoundException $e) { - } } elseif ($fileId) { $file = $this->documentService->getFileById($fileId); - $readOnly = !$file->isUpdateable(); } else { return new DataResponse('No valid file argument provided', 500); } + $readOnly = $this->documentService->isReadOnly($file, $token); + $this->sessionService->removeInactiveSessions($file->getId()); $activeSessions = $this->sessionService->getActiveSessions($file->getId()); if ($forceRecreate || count($activeSessions) === 0) { |