Skip to content

Commit

Permalink
Merge pull request #24605 from nextcloud/enh/share-deck
Browse files Browse the repository at this point in the history
Add deck share provider support
  • Loading branch information
rullzer authored Dec 10, 2020
2 parents 16be144 + c4ea37b commit 3c693db
Show file tree
Hide file tree
Showing 32 changed files with 279 additions and 35 deletions.
25 changes: 25 additions & 0 deletions apps/admin_audit/lib/Actions/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ public function shared(array $params) {
'id',
]
);
} elseif ($params['shareType'] === IShare::TYPE_DECK) {
$this->log(
'The %s "%s" with ID "%s" has been shared to the deck card "%s" with permissions "%s" (Share ID: %s)',
$params,
[
'itemType',
'itemTarget',
'itemSource',
'shareWith',
'permissions',
'id',
]
);
}
}

Expand Down Expand Up @@ -250,6 +263,18 @@ public function unshare(array $params) {
'id',
]
);
} elseif ($params['shareType'] === IShare::TYPE_DECK) {
$this->log(
'The %s "%s" with ID "%s" has been unshared from the deck card "%s" (Share ID: %s)',
$params,
[
'itemType',
'fileTarget',
'itemSource',
'shareWith',
'id',
]
);
}
}

Expand Down
1 change: 1 addition & 0 deletions apps/dav/lib/Connector/Sabre/SharesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ private function getShare(\OCP\Files\Node $node): array {
IShare::TYPE_EMAIL,
IShare::TYPE_ROOM,
IShare::TYPE_CIRCLE,
IShare::TYPE_DECK,
];
foreach ($requestedShareTypes as $requestedShareType) {
$shares = $this->shareManager->getSharesBy(
Expand Down
1 change: 1 addition & 0 deletions apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ public function sharesGetPropertiesDataProvider() {
[[IShare::TYPE_LINK]],
[[IShare::TYPE_REMOTE]],
[[IShare::TYPE_ROOM]],
[[IShare::TYPE_DECK]],
[[IShare::TYPE_USER, IShare::TYPE_GROUP]],
[[IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_LINK]],
[[IShare::TYPE_USER, IShare::TYPE_LINK]],
Expand Down
3 changes: 2 additions & 1 deletion apps/files/lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ private function getShareTypes(Node $node) {
IShare::TYPE_LINK,
IShare::TYPE_REMOTE,
IShare::TYPE_EMAIL,
IShare::TYPE_ROOM
IShare::TYPE_ROOM,
IShare::TYPE_DECK,
];
foreach ($requestedShareTypes as $requestedShareType) {
// one of each type is enough to find out about the types
Expand Down
2 changes: 1 addition & 1 deletion apps/files/lib/Service/OwnershipTransferService.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ private function collectUsersShares(string $sourceUid,

$shares = [];
$progress = new ProgressBar($output);
foreach ([IShare::TYPE_GROUP, IShare::TYPE_USER, IShare::TYPE_LINK, IShare::TYPE_REMOTE, IShare::TYPE_ROOM, IShare::TYPE_EMAIL, IShare::TYPE_CIRCLE] as $shareType) {
foreach ([IShare::TYPE_GROUP, IShare::TYPE_USER, IShare::TYPE_LINK, IShare::TYPE_REMOTE, IShare::TYPE_ROOM, IShare::TYPE_EMAIL, IShare::TYPE_CIRCLE, IShare::TYPE_DECK] as $shareType) {
$offset = 0;
while (true) {
$sharePage = $this->shareManager->getSharesBy($sourceUid, $shareType, null, true, 50, $offset);
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/js/dist/additionalScripts.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/files_sharing/js/dist/additionalScripts.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/files_sharing/js/dist/files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/files_sharing/js/dist/files_sharing_tab.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/files_sharing/js/dist/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/files_sharing/js/dist/main.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 28 additions & 2 deletions apps/files_sharing/lib/Controller/DeletedShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ private function formatShare(IShare $share): array {
$result = array_merge($result, $this->getRoomShareHelper()->formatShare($share));
} catch (QueryException $e) {
}
} elseif ($share->getShareType() === IShare::TYPE_DECK) {
$result['share_with'] = $share->getSharedWith();
$result['share_with_displayname'] = '';

try {
$result = array_merge($result, $this->getDeckShareHelper()->formatShare($share));
} catch (QueryException $e) {
}
}

return $result;
Expand All @@ -162,8 +170,9 @@ private function formatShare(IShare $share): array {
public function index(): DataResponse {
$groupShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_GROUP, null, -1, 0);
$roomShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_ROOM, null, -1, 0);
$deckShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_DECK, null, -1, 0);

$shares = array_merge($groupShares, $roomShares);
$shares = array_merge($groupShares, $roomShares, $deckShares);

$shares = array_map(function (IShare $share) {
return $this->formatShare($share);
Expand Down Expand Up @@ -211,6 +220,23 @@ private function getRoomShareHelper() {
throw new QueryException();
}

return $this->serverContainer->query('\OCA\Talk\Share\Helper\DeletedShareAPIController');
return $this->serverContainer->get('\OCA\Talk\Share\Helper\DeletedShareAPIController');
}

/**
* Returns the helper of ShareAPIHelper for deck shares.
*
* If the Deck application is not enabled or the helper is not available
* a QueryException is thrown instead.
*
* @return \OCA\Deck\Sharing\ShareAPIHelper
* @throws QueryException
*/
private function getDeckShareHelper() {
if (!$this->appManager->isEnabledForUser('deck')) {
throw new QueryException();
}

return $this->serverContainer->get('\OCA\Deck\Sharing\ShareAPIHelper');
}
}
Loading

0 comments on commit 3c693db

Please sign in to comment.