prevent download on user shares according to the share download permission

Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
This commit is contained in:
Julien Veyssier 2022-06-20 17:30:33 +02:00 коммит произвёл Julius Härtl
Родитель c6dff61a27
Коммит 6f904ca04b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4C614C6ED2CDE6DF
2 изменённых файлов: 26 добавлений и 0 удалений

Просмотреть файл

@ -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;
@ -147,6 +148,25 @@ class TokenManager {
}
}
}
// 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;
}

Просмотреть файл

@ -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;