From d4a82113a05fd2d2ab4f9e2117878b631453d4a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 21 Jun 2019 14:46:27 +0200 Subject: Implement public folder editing (fixes #29) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Service/ApiService.php | 12 +++++++----- lib/Service/DocumentService.php | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/Service/ApiService.php b/lib/Service/ApiService.php index c24ba7936..83a7a8124 100644 --- a/lib/Service/ApiService.php +++ b/lib/Service/ApiService.php @@ -39,6 +39,7 @@ use OCP\Constants; use OCP\Files\NotFoundException; use OCP\ICacheFactory; use OCP\ILogger; +use OCP\IRequest; use OCP\Lock\LockedException; class ApiService { @@ -48,7 +49,8 @@ class ApiService { protected $documentService; protected $logger; - public function __construct(ICacheFactory $cacheFactory, SessionService $sessionService, DocumentService $documentService, ILogger $logger) { + public function __construct(IRequest $request, ICacheFactory $cacheFactory, SessionService $sessionService, DocumentService $documentService, ILogger $logger) { + $this->request = $request; $this->cache = $cacheFactory->createDistributed('textSession'); $this->sessionService = $sessionService; $this->documentService = $documentService; @@ -61,7 +63,7 @@ class ApiService { /** @var File $file */ $file = null; if ($token) { - $file = $this->documentService->getFileByShareToken($token, $filePath); + $file = $this->documentService->getFileByShareToken($token, $this->request->getParam('filePath')); try { $this->documentService->checkSharePermissions($token, Constants::PERMISSION_UPDATE); $readOnly = false; @@ -131,7 +133,7 @@ class ApiService { */ public function push($documentId, $sessionId, $sessionToken, $version, $steps, $token = null): DataResponse { if ($token) { - $file = $this->documentService->getFileByShareToken($token); + $file = $this->documentService->getFileByShareToken($token, $this->request->getParam('filePath')); } else { $file = $this->documentService->getFileById($documentId); } @@ -161,12 +163,12 @@ class ApiService { ]; try { - $result['document'] = $this->documentService->autosave($documentId, $version, $autosaveContent, $force, $manualSave, $token); + $result['document'] = $this->documentService->autosave($documentId, $version, $autosaveContent, $force, $manualSave, $token, $this->request->getParam('filePath')); } catch (DocumentSaveConflictException $e) { try { if ($token) { /** @var File $file */ - $file = $this->documentService->getFileByShareToken($token); + $file = $this->documentService->getFileByShareToken($token, $this->request->getParam('filePath')); } else { $file = $this->documentService->getFileById($documentId); } diff --git a/lib/Service/DocumentService.php b/lib/Service/DocumentService.php index e35898f77..f27b1c5ed 100644 --- a/lib/Service/DocumentService.php +++ b/lib/Service/DocumentService.php @@ -225,7 +225,7 @@ class DocumentService { * @throws NotPermittedException * @throws ShareNotFound */ - public function autosave($documentId, $version, $autoaveDocument, $force = false, $manualSave = false, $token = null): Document { + public function autosave($documentId, $version, $autoaveDocument, $force = false, $manualSave = false, $token = null, $filePath = null): Document { /** @var Document $document */ $document = $this->documentMapper->find($documentId); @@ -233,7 +233,7 @@ class DocumentService { if (!$token) { $file = $this->getFileById($documentId); } else { - $file = $this->getFileByShareToken($token); + $file = $this->getFileByShareToken($token, $filePath); } if ($this->isReadOnly($file, $token)) { -- cgit v1.2.3