Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Open files read only if locked
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr authored and backportbot[bot] committed Apr 21, 2022
commit 56357a26b2682183086b6ca6dbe541b7de87810e
12 changes: 4 additions & 8 deletions lib/Service/ApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

use Exception;
use OC\Files\Node\File;
use OCA\Text\AppInfo\Application;
use OCA\Text\DocumentHasUnsavedChangesException;
use OCA\Text\DocumentSaveConflictException;
use OCA\Text\VersionMismatchException;
Expand All @@ -37,6 +38,7 @@
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;
Expand All @@ -63,7 +65,6 @@ public function __construct(IRequest $request,

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'));
Expand All @@ -77,19 +78,14 @@ public function create($fileId = null, $filePath = null, $token = null, $guestNa
} 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) {
Expand Down