summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_sharing/lib/Controller/DeletedShareAPIController.php53
1 files changed, 48 insertions, 5 deletions
diff --git a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
index d95b434e48f..7648c4e432d 100644
--- a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
@@ -26,14 +26,17 @@ declare(strict_types=1);
namespace OCA\Files_Sharing\Controller;
+use OCP\App\IAppManager;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\AppFramework\OCSController;
+use OCP\AppFramework\QueryException;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\IGroupManager;
use OCP\IRequest;
+use OCP\IServerContainer;
use OCP\IUserManager;
use OCP\Share\Exceptions\GenericShareException;
use OCP\Share\Exceptions\ShareNotFound;
@@ -57,13 +60,21 @@ class DeletedShareAPIController extends OCSController {
/** @var IRootFolder */
private $rootFolder;
+ /** @var IAppManager */
+ private $appManager;
+
+ /** @var IServerContainer */
+ private $serverContainer;
+
public function __construct(string $appName,
IRequest $request,
ShareManager $shareManager,
string $UserId,
IUserManager $userManager,
IGroupManager $groupManager,
- IRootFolder $rootFolder) {
+ IRootFolder $rootFolder,
+ IAppManager $appManager,
+ IServerContainer $serverContainer) {
parent::__construct($appName, $request);
$this->shareManager = $shareManager;
@@ -71,6 +82,8 @@ class DeletedShareAPIController extends OCSController {
$this->userManager = $userManager;
$this->groupManager = $groupManager;
$this->rootFolder = $rootFolder;
+ $this->appManager = $appManager;
+ $this->serverContainer = $serverContainer;
}
private function formatShare(IShare $share): array {
@@ -120,9 +133,19 @@ class DeletedShareAPIController extends OCSController {
$result['expiration'] = $expiration->format('Y-m-d 00:00:00');
}
- $group = $this->groupManager->get($share->getSharedWith());
- $result['share_with'] = $share->getSharedWith();
- $result['share_with_displayname'] = $group !== null ? $group->getDisplayName() : $share->getSharedWith();
+ if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ $group = $this->groupManager->get($share->getSharedWith());
+ $result['share_with'] = $share->getSharedWith();
+ $result['share_with_displayname'] = $group !== null ? $group->getDisplayName() : $share->getSharedWith();
+ } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_ROOM) {
+ $result['share_with'] = $share->getSharedWith();
+ $result['share_with_displayname'] = '';
+
+ try {
+ $result = array_merge($result, $this->getRoomShareHelper()->formatShare($share));
+ } catch (QueryException $e) {
+ }
+ }
return $result;
@@ -132,7 +155,10 @@ class DeletedShareAPIController extends OCSController {
* @NoAdminRequired
*/
public function index(): DataResponse {
- $shares = $this->shareManager->getDeletedSharedWith($this->userId, \OCP\Share::SHARE_TYPE_GROUP, null, -1, 0);
+ $groupShares = $this->shareManager->getDeletedSharedWith($this->userId, \OCP\Share::SHARE_TYPE_GROUP, null, -1, 0);
+ $roomShares = $this->shareManager->getDeletedSharedWith($this->userId, \OCP\Share::SHARE_TYPE_ROOM, null, -1, 0);
+
+ $shares = array_merge($groupShares, $roomShares);
$shares = array_map(function (IShare $share) {
return $this->formatShare($share);
@@ -165,4 +191,21 @@ class DeletedShareAPIController extends OCSController {
return new DataResponse([]);
}
+
+ /**
+ * Returns the helper of DeletedShareAPIController for room shares.
+ *
+ * If the Talk application is not enabled or the helper is not available
+ * a QueryException is thrown instead.
+ *
+ * @return \OCA\Spreed\Share\Helper\DeletedShareAPIController
+ * @throws QueryException
+ */
+ private function getRoomShareHelper() {
+ if (!$this->appManager->isEnabledForUser('spreed')) {
+ throw new QueryException();
+ }
+
+ return $this->serverContainer->query('\OCA\Spreed\Share\Helper\DeletedShareAPIController');
+ }
}