diff options
author | Julien Veyssier <eneiluj@posteo.net> | 2022-06-20 18:30:33 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2022-08-03 11:33:12 +0300 |
commit | 4ef5088d205ffa6c529fdab47f0b6bb99ee2f63c (patch) | |
tree | 2f5dbc91739ab693e2c05fa5509e2ca74d7bf1bf | |
parent | 5298a9f946edc37e0e8d3e8e5078238e289daca0 (diff) |
prevent download on user shares according to the share download permissionenh/2267/prevent-download
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
-rw-r--r-- | lib/TokenManager.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/TokenManager.php b/lib/TokenManager.php index 95a81081..ec6bf35c 100644 --- a/lib/TokenManager.php +++ b/lib/TokenManager.php @@ -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,21 @@ 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('OCA\Files_Sharing\SharedStorage')) { + /** @var SharedStorage $storage */ + $share = $storage->getShare(); + $canDownload = $share->getAttributes()->getAttribute('permissions', 'download'); + if ($canDownload !== null && !$canDownload) { + $hideDownload = true; + break; + } + } + } } catch (\Exception $e) { throw $e; } |