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
20 changes: 20 additions & 0 deletions lib/TokenManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
namespace OCA\Richdocuments;

use OC\Files\Filesystem;
use OCA\Files_Sharing\SharedStorage;
use OCA\Richdocuments\Db\Direct;
use OCA\Richdocuments\Db\WopiMapper;
use OCA\Richdocuments\Db\Wopi;
Expand Down Expand Up @@ -147,6 +148,25 @@ public function getToken($fileId, $shareToken = null, $editoruid = null, $direct
}
}
}

// disable download if at least one shared access has it disabled

foreach ($files as $file) {
$storage = $file->getStorage();
// using string as we have no guarantee that "files_sharing" app is loaded
if ($storage->instanceOfStorage(SharedStorage::class)) {
if (!method_exists(SharedStorage::class, 'getAttributes')) {
break;
}
/** @var SharedStorage $storage */
$share = $storage->getShare();
$canDownload = $share->getAttributes()->getAttribute('permissions', 'download');
if ($canDownload !== null && !$canDownload) {
$hideDownload = true;
break;
}
}
}
} catch (\Exception $e) {
throw $e;
}
Expand Down
6 changes: 6 additions & 0 deletions tests/stub.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ namespace Doctrine\DBAL\Platforms {
class SqlitePlatform {}
}

namespace OCA\Files_Sharing {
use \OCP\Share\IShare;
class SharedStorage {
public function getShare(): IShare {}
}
}

namespace OCA\Files_Sharing\Event {
use \OCP\Share\IShare;
Expand Down