From 20d2ce582a89e5a9ea50d7c6b02a0e712df93d22 Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Wed, 19 Oct 2016 00:56:01 +0530 Subject: [PATCH] Don't ignore non-updatable files Don't discriminate with these files; let them have the right to join the session or generate access token like other sessions --- controller/sessioncontroller.php | 13 +++---------- js/documents.js | 2 ++ lib/db/wopi.php | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/controller/sessioncontroller.php b/controller/sessioncontroller.php index 7f63855d..ecdc7345 100644 --- a/controller/sessioncontroller.php +++ b/controller/sessioncontroller.php @@ -99,16 +99,9 @@ class SessionController extends Controller{ $view = \OC\Files\Filesystem::getView(); $path = $view->getPath($fileId); - if ($view->isUpdatable($path)) { - $file = new File($fileId); - $response = Db\Session::start($this->uid, $file); - } else { - $info = $view->getFileInfo($path); - $response = [ - 'permissions' => $info['permissions'], - 'id' => $fileId - ]; - } + $file = new File($fileId); + $response = Db\Session::start($this->uid, $file); + $response = array_merge( $response, [ 'status'=>'success' ] diff --git a/js/documents.js b/js/documents.js index f7495cbb..99c2dd3c 100644 --- a/js/documents.js +++ b/js/documents.js @@ -18,6 +18,7 @@ $.widget('oc.documentGrid', { .then(function(){ that._render(); + // TODO: Handle all of this logic by sending UserCanWrite: false to loolwsd if (!documentsMain.isGuest) { var editGroups = $('#edit_groups').val() .split('|') @@ -658,6 +659,7 @@ var documentsMain = { documentsMain.esId = response.es_id; documentsMain.memberId = response.member_id; + documentsMain.canEdit = response.permissions & OC.PERMISSION_UPDATE; documentsMain.loadDocument(); diff --git a/lib/db/wopi.php b/lib/db/wopi.php index fcff1c54..c826a1a5 100644 --- a/lib/db/wopi.php +++ b/lib/db/wopi.php @@ -49,7 +49,7 @@ class Wopi extends \OCA\Richdocuments\Db{ // Get the virtual path (if the file is shared). $path = $view->getPath($fileId); - if (!$view->is_file($path) || !$view->isUpdatable($path)) { + if (!$view->is_file($path)) { throw new \Exception('Invalid fileId.'); }