Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions js/editor-rich.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor-rich.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/files-modal.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/files-modal.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions js/text-files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-files.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-text.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-text.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-viewer.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/vendors.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/vendors.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/Cron/Cleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ protected function run($argument) {
continue;
}

$this->documentService->unlock($session->getDocumentId());

try {
$this->logger->debug('Resetting document ' . $session->getDocumentId() . '');
$this->documentService->resetDocument($session->getDocumentId());
Expand Down
26 changes: 17 additions & 9 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 All @@ -113,11 +109,23 @@ public function create($fileId = null, $filePath = null, $token = null, $guestNa
$this->logger->logException($e, ['level' => ILogger::INFO]);
$content = null;
}

$lockInfo = $this->documentService->getLockInfo($file);
if ($lockInfo && $lockInfo->getType() === ILock::TYPE_APP && $lockInfo->getOwner() === Application::APP_NAME) {
$lockInfo = null;
}

$isLocked = $this->documentService->lock($file->getId());
if (!$isLocked) {
$readOnly = true;
}

return new DataResponse([
'document' => $document,
'session' => $session,
'readOnly' => $readOnly,
'content' => $content
'content' => $content,
'lock' => $lockInfo,
]);
}

Expand Down
Loading