Skip to content

Commit af5a94d

Browse files
committed
Indicate preview availability in share api responses
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
1 parent 96f8cd0 commit af5a94d

File tree

6 files changed

+109
-11
lines changed

6 files changed

+109
-11
lines changed

apps/files_sharing/js/dist/files_sharing.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files_sharing/js/dist/files_sharing.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files_sharing/js/sharedfilelist.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@
353353
id: share.file_source,
354354
icon: OC.MimeType.getIconUrl(share.mimetype),
355355
mimetype: share.mimetype,
356+
hasPreview: share.has_preview,
356357
tags: share.tags || []
357358
}
358359
if (share.item_type === 'folder') {

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
use OCP\IConfig;
6060
use OCP\IGroupManager;
6161
use OCP\IL10N;
62+
use OCP\IPreview;
6263
use OCP\IRequest;
6364
use OCP\IServerContainer;
6465
use OCP\IURLGenerator;
@@ -100,6 +101,8 @@ class ShareAPIController extends OCSController {
100101
private $appManager;
101102
/** @var IServerContainer */
102103
private $serverContainer;
104+
/** @var IPreview */
105+
private $previewManager;
103106

104107
/**
105108
* Share20OCS constructor.
@@ -129,7 +132,8 @@ public function __construct(
129132
IL10N $l10n,
130133
IConfig $config,
131134
IAppManager $appManager,
132-
IServerContainer $serverContainer
135+
IServerContainer $serverContainer,
136+
IPreview $previewManager
133137
) {
134138
parent::__construct($appName, $request);
135139

@@ -144,6 +148,7 @@ public function __construct(
144148
$this->config = $config;
145149
$this->appManager = $appManager;
146150
$this->serverContainer = $serverContainer;
151+
$this->previewManager = $previewManager;
147152
}
148153

149154
/**
@@ -204,6 +209,7 @@ protected function formatShare(IShare $share, Node $recipientNode = null): array
204209
}
205210

206211
$result['mimetype'] = $node->getMimetype();
212+
$result['has_preview'] = $this->previewManager->isAvailable($node);
207213
$result['storage_id'] = $node->getStorage()->getId();
208214
$result['storage'] = $node->getStorage()->getCache()->getNumericStorageId();
209215
$result['item_source'] = $node->getId();

apps/files_sharing/tests/ApiTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
use OCP\AppFramework\OCS\OCSNotFoundException;
4444
use OCP\IConfig;
4545
use OCP\IL10N;
46+
use OCP\IPreview;
4647
use OCP\IRequest;
4748
use OCP\IServerContainer;
4849
use OCP\Share\IShare;
@@ -114,6 +115,7 @@ private function createOCS($userId) {
114115
$config = $this->createMock(IConfig::class);
115116
$appManager = $this->createMock(IAppManager::class);
116117
$serverContainer = $this->createMock(IServerContainer::class);
118+
$previewManager = $this->createMock(IPreview::class);
117119

118120
return new ShareAPIController(
119121
self::APP_NAME,
@@ -127,7 +129,8 @@ private function createOCS($userId) {
127129
$l,
128130
$config,
129131
$appManager,
130-
$serverContainer
132+
$serverContainer,
133+
$previewManager
131134
);
132135
}
133136

0 commit comments

Comments
 (0)