diff options
author | Julius Härtl <jus@bitgrid.net> | 2022-04-21 13:33:56 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2022-04-21 14:27:44 +0300 |
commit | 53d1012f7fb2373e4067b5efc44526175f3ac7f8 (patch) | |
tree | 69078809b8c5413e31cc92467cd6744911a2e4cd | |
parent | 8c00c8eb25b622ac2f32b9c6e2928ca8fcae7feb (diff) |
Open files read only if locked
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-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) { |