Merge pull request #24605 from nextcloud/enh/share-deck

Add deck share provider support
This commit is contained in:
Roeland Jago Douma 2020-12-10 14:30:08 +01:00 committed by GitHub
commit 3c693db0ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 279 additions and 35 deletions

View File

@ -146,6 +146,19 @@ class Sharing extends Action {
'id', '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',
]
);
} }
} }
@ -250,6 +263,18 @@ class Sharing extends Action {
'id', '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',
]
);
} }
} }

View File

@ -121,6 +121,7 @@ class SharesPlugin extends \Sabre\DAV\ServerPlugin {
IShare::TYPE_EMAIL, IShare::TYPE_EMAIL,
IShare::TYPE_ROOM, IShare::TYPE_ROOM,
IShare::TYPE_CIRCLE, IShare::TYPE_CIRCLE,
IShare::TYPE_DECK,
]; ];
foreach ($requestedShareTypes as $requestedShareType) { foreach ($requestedShareTypes as $requestedShareType) {
$shares = $this->shareManager->getSharesBy( $shares = $this->shareManager->getSharesBy(

View File

@ -276,6 +276,7 @@ class SharesPluginTest extends \Test\TestCase {
[[IShare::TYPE_LINK]], [[IShare::TYPE_LINK]],
[[IShare::TYPE_REMOTE]], [[IShare::TYPE_REMOTE]],
[[IShare::TYPE_ROOM]], [[IShare::TYPE_ROOM]],
[[IShare::TYPE_DECK]],
[[IShare::TYPE_USER, IShare::TYPE_GROUP]], [[IShare::TYPE_USER, IShare::TYPE_GROUP]],
[[IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_LINK]], [[IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_LINK]],
[[IShare::TYPE_USER, IShare::TYPE_LINK]], [[IShare::TYPE_USER, IShare::TYPE_LINK]],

View File

@ -221,7 +221,8 @@ class ApiController extends Controller {
IShare::TYPE_LINK, IShare::TYPE_LINK,
IShare::TYPE_REMOTE, IShare::TYPE_REMOTE,
IShare::TYPE_EMAIL, IShare::TYPE_EMAIL,
IShare::TYPE_ROOM IShare::TYPE_ROOM,
IShare::TYPE_DECK,
]; ];
foreach ($requestedShareTypes as $requestedShareType) { foreach ($requestedShareTypes as $requestedShareType) {
// one of each type is enough to find out about the types // one of each type is enough to find out about the types

View File

@ -252,7 +252,7 @@ class OwnershipTransferService {
$shares = []; $shares = [];
$progress = new ProgressBar($output); $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; $offset = 0;
while (true) { while (true) {
$sharePage = $this->shareManager->getSharesBy($sourceUid, $shareType, null, true, 50, $offset); $sharePage = $this->shareManager->getSharesBy($sourceUid, $shareType, null, true, 50, $offset);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/js/",r(r.s=341)}({341:function(e,t){Object.assign(OC,{Share:{SHARE_TYPE_USER:0,SHARE_TYPE_GROUP:1,SHARE_TYPE_LINK:3,SHARE_TYPE_EMAIL:4,SHARE_TYPE_REMOTE:6,SHARE_TYPE_CIRCLE:7,SHARE_TYPE_GUEST:8,SHARE_TYPE_REMOTE_GROUP:9,SHARE_TYPE_ROOM:10}})}}); !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/js/",r(r.s=341)}({341:function(e,t){Object.assign(OC,{Share:{SHARE_TYPE_USER:0,SHARE_TYPE_GROUP:1,SHARE_TYPE_LINK:3,SHARE_TYPE_EMAIL:4,SHARE_TYPE_REMOTE:6,SHARE_TYPE_CIRCLE:7,SHARE_TYPE_GUEST:8,SHARE_TYPE_REMOTE_GROUP:9,SHARE_TYPE_ROOM:10,SHARE_TYPE_DECK:12}})}});
//# sourceMappingURL=main.js.map //# sourceMappingURL=main.js.map

File diff suppressed because one or more lines are too long

View File

@ -151,6 +151,14 @@ class DeletedShareAPIController extends OCSController {
$result = array_merge($result, $this->getRoomShareHelper()->formatShare($share)); $result = array_merge($result, $this->getRoomShareHelper()->formatShare($share));
} catch (QueryException $e) { } 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; return $result;
@ -162,8 +170,9 @@ class DeletedShareAPIController extends OCSController {
public function index(): DataResponse { public function index(): DataResponse {
$groupShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_GROUP, null, -1, 0); $groupShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_GROUP, null, -1, 0);
$roomShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_ROOM, 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) { $shares = array_map(function (IShare $share) {
return $this->formatShare($share); return $this->formatShare($share);
@ -211,6 +220,23 @@ class DeletedShareAPIController extends OCSController {
throw new QueryException(); 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');
} }
} }

View File

@ -303,6 +303,14 @@ class ShareAPIController extends OCSController {
$result = array_merge($result, $this->getRoomShareHelper()->formatShare($share)); $result = array_merge($result, $this->getRoomShareHelper()->formatShare($share));
} catch (QueryException $e) { } 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) {
}
} }
@ -603,6 +611,12 @@ class ShareAPIController extends OCSController {
} catch (QueryException $e) { } catch (QueryException $e) {
throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support room shares', [$path->getPath()])); throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support room shares', [$path->getPath()]));
} }
} elseif ($shareType === IShare::TYPE_DECK) {
try {
$this->getDeckShareHelper()->createShare($share, $shareWith, $permissions, $expireDate);
} catch (QueryException $e) {
throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support room shares', [$path->getPath()]));
}
} else { } else {
throw new OCSBadRequestException($this->l->t('Unknown share type')); throw new OCSBadRequestException($this->l->t('Unknown share type'));
} }
@ -635,8 +649,9 @@ class ShareAPIController extends OCSController {
$groupShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_GROUP, $node, -1, 0); $groupShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_GROUP, $node, -1, 0);
$circleShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_CIRCLE, $node, -1, 0); $circleShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_CIRCLE, $node, -1, 0);
$roomShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_ROOM, $node, -1, 0); $roomShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_ROOM, $node, -1, 0);
$deckShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_DECK, $node, -1, 0);
$shares = array_merge($userShares, $groupShares, $circleShares, $roomShares); $shares = array_merge($userShares, $groupShares, $circleShares, $roomShares, $deckShares);
$filteredShares = array_filter($shares, function (IShare $share) { $filteredShares = array_filter($shares, function (IShare $share) {
return $share->getShareOwner() !== $this->currentUser; return $share->getShareOwner() !== $this->currentUser;
@ -1296,6 +1311,14 @@ class ShareAPIController extends OCSController {
} }
} }
if ($share->getShareType() === IShare::TYPE_DECK) {
try {
return $this->getDeckShareHelper()->canAccessShare($share, $this->currentUser);
} catch (QueryException $e) {
return false;
}
}
return false; return false;
} }
@ -1371,7 +1394,8 @@ class ShareAPIController extends OCSController {
*/ */
protected function canDeleteShareFromSelf(\OCP\Share\IShare $share): bool { protected function canDeleteShareFromSelf(\OCP\Share\IShare $share): bool {
if ($share->getShareType() !== IShare::TYPE_GROUP && if ($share->getShareType() !== IShare::TYPE_GROUP &&
$share->getShareType() !== IShare::TYPE_ROOM $share->getShareType() !== IShare::TYPE_ROOM &&
$share->getShareType() !== IShare::TYPE_DECK
) { ) {
return false; return false;
} }
@ -1400,6 +1424,14 @@ class ShareAPIController extends OCSController {
} }
} }
if ($share->getShareType() === IShare::TYPE_DECK) {
try {
return $this->getDeckShareHelper()->canAccessShare($share, $this->currentUser);
} catch (QueryException $e) {
return false;
}
}
return false; return false;
} }
@ -1474,6 +1506,15 @@ class ShareAPIController extends OCSController {
// Do nothing, just try the other share type // Do nothing, just try the other share type
} }
try {
if ($this->shareManager->shareProviderExists(IShare::TYPE_DECK)) {
$share = $this->shareManager->getShareById('deck:' . $id, $this->currentUser);
return $share;
}
} catch (ShareNotFound $e) {
// Do nothing, just try the other share type
}
if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) { if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
throw new ShareNotFound(); throw new ShareNotFound();
} }
@ -1517,9 +1558,25 @@ class ShareAPIController extends OCSController {
throw new QueryException(); throw new QueryException();
} }
return $this->serverContainer->query('\OCA\Talk\Share\Helper\ShareAPIController'); return $this->serverContainer->get('\OCA\Talk\Share\Helper\ShareAPIController');
} }
/**
* 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');
}
/** /**
* @param string $viewer * @param string $viewer
@ -1536,7 +1593,8 @@ class ShareAPIController extends OCSController {
IShare::TYPE_EMAIL, IShare::TYPE_EMAIL,
IShare::TYPE_EMAIL, IShare::TYPE_EMAIL,
IShare::TYPE_CIRCLE, IShare::TYPE_CIRCLE,
IShare::TYPE_ROOM IShare::TYPE_ROOM,
IShare::TYPE_DECK
]; ];
// Should we assume that the (currentUser) viewer is the owner of the node !? // Should we assume that the (currentUser) viewer is the owner of the node !?
@ -1689,6 +1747,8 @@ class ShareAPIController extends OCSController {
// TALK SHARES // TALK SHARES
$roomShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_ROOM, $path, $reshares, -1, 0); $roomShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_ROOM, $path, $reshares, -1, 0);
$deckShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_DECK, $path, $reshares, -1, 0);
// FEDERATION // FEDERATION
if ($this->shareManager->outgoingServer2ServerSharesAllowed()) { if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
$federatedShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_REMOTE, $path, $reshares, -1, 0); $federatedShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_REMOTE, $path, $reshares, -1, 0);
@ -1701,7 +1761,7 @@ class ShareAPIController extends OCSController {
$federatedGroupShares = []; $federatedGroupShares = [];
} }
return array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares, $roomShares, $federatedShares, $federatedGroupShares); return array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares, $roomShares, $deckShares, $federatedShares, $federatedGroupShares);
} }

View File

@ -83,6 +83,7 @@ class ShareesAPIController extends OCSController {
'emails' => [], 'emails' => [],
'circles' => [], 'circles' => [],
'rooms' => [], 'rooms' => [],
'deck' => [],
], ],
'users' => [], 'users' => [],
'groups' => [], 'groups' => [],
@ -92,6 +93,7 @@ class ShareesAPIController extends OCSController {
'lookup' => [], 'lookup' => [],
'circles' => [], 'circles' => [],
'rooms' => [], 'rooms' => [],
'deck' => [],
'lookupEnabled' => false, 'lookupEnabled' => false,
]; ];
@ -183,6 +185,10 @@ class ShareesAPIController extends OCSController {
if ($this->shareManager->shareProviderExists(IShare::TYPE_ROOM)) { if ($this->shareManager->shareProviderExists(IShare::TYPE_ROOM)) {
$shareTypes[] = IShare::TYPE_ROOM; $shareTypes[] = IShare::TYPE_ROOM;
} }
if ($this->shareManager->shareProviderExists(IShare::TYPE_DECK)) {
$shareTypes[] = IShare::TYPE_DECK;
}
} else { } else {
$shareTypes[] = IShare::TYPE_GROUP; $shareTypes[] = IShare::TYPE_GROUP;
$shareTypes[] = IShare::TYPE_EMAIL; $shareTypes[] = IShare::TYPE_EMAIL;
@ -193,6 +199,10 @@ class ShareesAPIController extends OCSController {
$shareTypes[] = IShare::TYPE_CIRCLE; $shareTypes[] = IShare::TYPE_CIRCLE;
} }
if ($this->shareManager->shareProviderExists(IShare::TYPE_DECK)) {
$shareTypes[] = IShare::TYPE_DECK;
}
if ($shareType !== null && is_array($shareType)) { if ($shareType !== null && is_array($shareType)) {
$shareTypes = array_intersect($shareTypes, $shareType); $shareTypes = array_intersect($shareTypes, $shareType);
} elseif (is_numeric($shareType)) { } elseif (is_numeric($shareType)) {

View File

@ -78,6 +78,8 @@ class MountProvider implements IMountProvider {
$shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_GROUP, null, -1)); $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_GROUP, null, -1));
$shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_CIRCLE, null, -1)); $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_CIRCLE, null, -1));
$shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_ROOM, null, -1)); $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_ROOM, null, -1));
$shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_DECK, null, -1));
// filter out excluded shares and group shares that includes self // filter out excluded shares and group shares that includes self
$shares = array_filter($shares, function (\OCP\Share\IShare $share) use ($user) { $shares = array_filter($shares, function (\OCP\Share\IShare $share) use ($user) {

View File

@ -29,13 +29,16 @@
:tooltip-message="share.type === SHARE_TYPES.SHARE_TYPE_USER ? share.shareWith : ''" :tooltip-message="share.type === SHARE_TYPES.SHARE_TYPE_USER ? share.shareWith : ''"
:menu-position="'left'" :menu-position="'left'"
:url="share.shareWithAvatar" /> :url="share.shareWithAvatar" />
<div v-tooltip.auto="tooltip" class="sharing-entry__desc"> <component :is="share.shareWithLink ? 'a' : 'div'"
:href="share.shareWithLink"
v-tooltip.auto="tooltip"
class="sharing-entry__desc">
<h5>{{ title }}</h5> <h5>{{ title }}</h5>
<p v-if="hasStatus"> <p v-if="hasStatus">
<span>{{ share.status.icon || '' }}</span> <span>{{ share.status.icon || '' }}</span>
<span>{{ share.status.message || '' }}</span> <span>{{ share.status.message || '' }}</span>
</p> </p>
</div> </component>
<Actions <Actions
menu-align="right" menu-align="right"
class="sharing-entry__actions" class="sharing-entry__actions"

View File

@ -186,6 +186,7 @@ export default {
this.SHARE_TYPES.SHARE_TYPE_CIRCLE, this.SHARE_TYPES.SHARE_TYPE_CIRCLE,
this.SHARE_TYPES.SHARE_TYPE_ROOM, this.SHARE_TYPES.SHARE_TYPE_ROOM,
this.SHARE_TYPES.SHARE_TYPE_GUEST, this.SHARE_TYPES.SHARE_TYPE_GUEST,
this.SHARE_TYPES.SHARE_TYPE_DECK,
] ]
if (OC.getCapabilities().files_sharing.public.enabled === true) { if (OC.getCapabilities().files_sharing.public.enabled === true) {
@ -365,6 +366,8 @@ export default {
return 'icon-circle' return 'icon-circle'
case this.SHARE_TYPES.SHARE_TYPE_ROOM: case this.SHARE_TYPES.SHARE_TYPE_ROOM:
return 'icon-room' return 'icon-room'
case this.SHARE_TYPES.SHARE_TYPE_DECK:
return 'icon-deck'
default: default:
return '' return ''
@ -384,6 +387,8 @@ export default {
desc = t('files_sharing', 'on {server}', { server: result.value.server }) desc = t('files_sharing', 'on {server}', { server: result.value.server })
} else if (result.value.shareType === this.SHARE_TYPES.SHARE_TYPE_EMAIL) { } else if (result.value.shareType === this.SHARE_TYPES.SHARE_TYPE_EMAIL) {
desc = result.value.shareWith desc = result.value.shareWith
} else {
desc = result.shareWithDescription ?? ''
} }
return { return {

View File

@ -32,5 +32,6 @@ Object.assign(OC, {
SHARE_TYPE_GUEST: 8, SHARE_TYPE_GUEST: 8,
SHARE_TYPE_REMOTE_GROUP: 9, SHARE_TYPE_REMOTE_GROUP: 9,
SHARE_TYPE_ROOM: 10, SHARE_TYPE_ROOM: 10,
SHARE_TYPE_DECK: 12,
}, },
}) })

View File

@ -31,6 +31,7 @@ export default {
SHARE_TYPE_REMOTE: OC.Share.SHARE_TYPE_REMOTE, SHARE_TYPE_REMOTE: OC.Share.SHARE_TYPE_REMOTE,
SHARE_TYPE_CIRCLE: OC.Share.SHARE_TYPE_CIRCLE, SHARE_TYPE_CIRCLE: OC.Share.SHARE_TYPE_CIRCLE,
SHARE_TYPE_GUEST: OC.Share.SHARE_TYPE_GUEST, SHARE_TYPE_GUEST: OC.Share.SHARE_TYPE_GUEST,
SHARE_TYPE_DECK: OC.Share.SHARE_TYPE_DECK,
SHARE_TYPE_REMOTE_GROUP: OC.Share.SHARE_TYPE_REMOTE_GROUP, SHARE_TYPE_REMOTE_GROUP: OC.Share.SHARE_TYPE_REMOTE_GROUP,
SHARE_TYPE_ROOM: OC.Share.SHARE_TYPE_ROOM, SHARE_TYPE_ROOM: OC.Share.SHARE_TYPE_ROOM,
}, },

View File

@ -150,6 +150,17 @@ export default class Share {
|| this.#share.share_with || this.#share.share_with
} }
/**
* Get the share with entity link
*
* @returns {string}
* @readonly
* @memberof Share
*/
get shareWithLink() {
return this.#share.share_with_link
}
/** /**
* Get the share with avatar if any * Get the share with avatar if any
* *

View File

@ -161,6 +161,8 @@ import escapeHTML from 'escape-html'
hasShares = true hasShares = true
} else if (shareType === OC.Share.SHARE_TYPE_ROOM) { } else if (shareType === OC.Share.SHARE_TYPE_ROOM) {
hasShares = true hasShares = true
} else if (shareType === OC.Share.SHARE_TYPE_DECK) {
hasShares = true
} }
}) })
OCA.Sharing.Util._updateFileActionIcon($tr, hasShares, hasLink) OCA.Sharing.Util._updateFileActionIcon($tr, hasShares, hasLink)

View File

@ -196,10 +196,10 @@ class ShareAPIControllerTest extends TestCase {
$this->expectExceptionMessage('Wrong share ID, share doesn\'t exist'); $this->expectExceptionMessage('Wrong share ID, share doesn\'t exist');
$this->shareManager $this->shareManager
->expects($this->exactly(5)) ->expects($this->exactly(6))
->method('getShareById') ->method('getShareById')
->willReturnCallback(function ($id) { ->willReturnCallback(function ($id) {
if ($id === 'ocinternal:42' || $id === 'ocRoomShare:42' || $id === 'ocFederatedSharing:42' || $id === 'ocCircleShare:42' || $id === 'ocMailShare:42') { if ($id === 'ocinternal:42' || $id === 'ocRoomShare:42' || $id === 'ocFederatedSharing:42' || $id === 'ocCircleShare:42' || $id === 'ocMailShare:42' || $id === 'deck:42') {
throw new \OCP\Share\Exceptions\ShareNotFound(); throw new \OCP\Share\Exceptions\ShareNotFound();
} else { } else {
throw new \Exception(); throw new \Exception();
@ -1558,7 +1558,7 @@ class ShareAPIControllerTest extends TestCase {
->with($share, $this->currentUser) ->with($share, $this->currentUser)
->willReturn($canAccessShareByHelper); ->willReturn($canAccessShareByHelper);
$this->serverContainer->method('query') $this->serverContainer->method('get')
->with('\OCA\Talk\Share\Helper\ShareAPIController') ->with('\OCA\Talk\Share\Helper\ShareAPIController')
->willReturn($helper); ->willReturn($helper);
} }
@ -2222,7 +2222,7 @@ class ShareAPIControllerTest extends TestCase {
} }
); );
$this->serverContainer->method('query') $this->serverContainer->method('get')
->with('\OCA\Talk\Share\Helper\ShareAPIController') ->with('\OCA\Talk\Share\Helper\ShareAPIController')
->willReturn($helper); ->willReturn($helper);
@ -2340,7 +2340,7 @@ class ShareAPIControllerTest extends TestCase {
} }
); );
$this->serverContainer->method('query') $this->serverContainer->method('get')
->with('\OCA\Talk\Share\Helper\ShareAPIController') ->with('\OCA\Talk\Share\Helper\ShareAPIController')
->willReturn($helper); ->willReturn($helper);
@ -4404,7 +4404,7 @@ class ShareAPIControllerTest extends TestCase {
->with($share) ->with($share)
->willReturn($formatShareByHelper); ->willReturn($formatShareByHelper);
$this->serverContainer->method('query') $this->serverContainer->method('get')
->with('\OCA\Talk\Share\Helper\ShareAPIController') ->with('\OCA\Talk\Share\Helper\ShareAPIController')
->willReturn($helper); ->willReturn($helper);
} }

View File

@ -123,6 +123,12 @@ class MountProviderTest extends \Test\TestCase {
$this->makeMockShare(8, 102, 'user2', '/share6', 31), $this->makeMockShare(8, 102, 'user2', '/share6', 31),
$this->makeMockShare(9, 102, 'user2', '/share6', 31), $this->makeMockShare(9, 102, 'user2', '/share6', 31),
]; ];
$deckShares = [
$this->makeMockShare(10, 103, 'user2', '/share7', 0),
$this->makeMockShare(11, 103, 'user1', '/share7', 31),
$this->makeMockShare(12, 103, 'user2', '/share7', 31),
$this->makeMockShare(13, 103, 'user2', '/share7', 31),
];
// tests regarding circles are made in the app itself. // tests regarding circles are made in the app itself.
$circleShares = []; $circleShares = [];
$this->user->expects($this->any()) $this->user->expects($this->any())
@ -144,16 +150,21 @@ class MountProviderTest extends \Test\TestCase {
->method('getSharedWith') ->method('getSharedWith')
->with('user1', IShare::TYPE_ROOM, null, -1) ->with('user1', IShare::TYPE_ROOM, null, -1)
->willReturn($roomShares); ->willReturn($roomShares);
$this->shareManager->expects($this->at(4))
->method('getSharedWith')
->with('user1', IShare::TYPE_DECK, null, -1)
->willReturn($deckShares);
$this->shareManager->expects($this->any()) $this->shareManager->expects($this->any())
->method('newShare') ->method('newShare')
->willReturnCallback(function () use ($rootFolder, $userManager) { ->willReturnCallback(function () use ($rootFolder, $userManager) {
return new \OC\Share20\Share($rootFolder, $userManager); return new \OC\Share20\Share($rootFolder, $userManager);
}); });
$mounts = $this->provider->getMountsForUser($this->user, $this->loader); $mounts = $this->provider->getMountsForUser($this->user, $this->loader);
$this->assertCount(3, $mounts); $this->assertCount(4, $mounts);
$this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[0]); $this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[0]);
$this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[1]); $this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[1]);
$this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[2]); $this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[2]);
$this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[3]);
$mountedShare1 = $mounts[0]->getShare(); $mountedShare1 = $mounts[0]->getShare();
$this->assertEquals('2', $mountedShare1->getId()); $this->assertEquals('2', $mountedShare1->getId());
$this->assertEquals('user2', $mountedShare1->getShareOwner()); $this->assertEquals('user2', $mountedShare1->getShareOwner());
@ -172,6 +183,12 @@ class MountProviderTest extends \Test\TestCase {
$this->assertEquals(102, $mountedShare3->getNodeId()); $this->assertEquals(102, $mountedShare3->getNodeId());
$this->assertEquals('/share6', $mountedShare3->getTarget()); $this->assertEquals('/share6', $mountedShare3->getTarget());
$this->assertEquals(31, $mountedShare3->getPermissions()); $this->assertEquals(31, $mountedShare3->getPermissions());
$mountedShare4 = $mounts[3]->getShare();
$this->assertEquals('12', $mountedShare4->getId());
$this->assertEquals('user2', $mountedShare4->getShareOwner());
$this->assertEquals(103, $mountedShare4->getNodeId());
$this->assertEquals('/share7', $mountedShare4->getTarget());
$this->assertEquals(31, $mountedShare4->getPermissions());
} }
public function mergeSharesDataProvider() { public function mergeSharesDataProvider() {
@ -337,6 +354,7 @@ class MountProviderTest extends \Test\TestCase {
// tests regarding circles are made in the app itself. // tests regarding circles are made in the app itself.
$circleShares = []; $circleShares = [];
$roomShares = []; $roomShares = [];
$deckShares = [];
$this->shareManager->expects($this->at(0)) $this->shareManager->expects($this->at(0))
->method('getSharedWith') ->method('getSharedWith')
->with('user1', IShare::TYPE_USER) ->with('user1', IShare::TYPE_USER)
@ -353,6 +371,10 @@ class MountProviderTest extends \Test\TestCase {
->method('getSharedWith') ->method('getSharedWith')
->with('user1', IShare::TYPE_ROOM, null, -1) ->with('user1', IShare::TYPE_ROOM, null, -1)
->willReturn($roomShares); ->willReturn($roomShares);
$this->shareManager->expects($this->at(4))
->method('getSharedWith')
->with('user1', IShare::TYPE_DECK, null, -1)
->willReturn($deckShares);
$this->shareManager->expects($this->any()) $this->shareManager->expects($this->any())
->method('newShare') ->method('newShare')
->willReturnCallback(function () use ($rootFolder, $userManager) { ->willReturnCallback(function () use ($rootFolder, $userManager) {

View File

@ -1613,12 +1613,6 @@
<code>getUserFolder</code> <code>getUserFolder</code>
</UndefinedInterfaceMethod> </UndefinedInterfaceMethod>
</file> </file>
<file src="apps/files_sharing/lib/Controller/DeletedShareAPIController.php">
<UndefinedDocblockClass occurrences="2">
<code>$this-&gt;getRoomShareHelper()</code>
<code>\OCA\Talk\Share\Helper\DeletedShareAPIController</code>
</UndefinedDocblockClass>
</file>
<file src="apps/files_sharing/lib/Controller/ShareAPIController.php"> <file src="apps/files_sharing/lib/Controller/ShareAPIController.php">
<InvalidScalarArgument occurrences="3"> <InvalidScalarArgument occurrences="3">
<code>$code</code> <code>$code</code>
@ -5051,16 +5045,13 @@
<code>FederatedShareProvider</code> <code>FederatedShareProvider</code>
<code>ShareByMailProvider</code> <code>ShareByMailProvider</code>
</InvalidNullableReturnType> </InvalidNullableReturnType>
<InvalidReturnStatement occurrences="5"> <InvalidReturnStatement occurrences="4">
<code>$provider</code> <code>$provider</code>
<code>$provider</code> <code>$provider</code>
<code>$shares</code>
<code>$this-&gt;roomShareProvider</code> <code>$this-&gt;roomShareProvider</code>
<code>$this-&gt;shareByCircleProvider</code> <code>$this-&gt;shareByCircleProvider</code>
</InvalidReturnStatement> </InvalidReturnStatement>
<InvalidReturnType occurrences="3"> <InvalidReturnType occurrences="1">
<code>getAllProviders</code>
<code>getProvider</code>
<code>getProviderForType</code> <code>getProviderForType</code>
</InvalidReturnType> </InvalidReturnType>
<NullableReturnStatement occurrences="6"> <NullableReturnStatement occurrences="6">

View File

@ -70,6 +70,11 @@ class Constants {
*/ */
public const SHARE_TYPE_ROOM = 10; public const SHARE_TYPE_ROOM = 10;
// const SHARE_TYPE_USERROOM = 11; // Internal type used by RoomShareProvider // const SHARE_TYPE_USERROOM = 11; // Internal type used by RoomShareProvider
/**
* @deprecated 21.0.0 - use IShare::TYPE_DECK instead
*/
public const SHARE_TYPE_DECK = 12;
// const SHARE_TYPE_DECK_USER = 13; // Internal type used by DeckShareProvider
public const FORMAT_NONE = -1; public const FORMAT_NONE = -1;
public const FORMAT_STATUSES = -2; public const FORMAT_STATUSES = -2;

View File

@ -248,6 +248,7 @@ class Manager implements IManager {
throw new \InvalidArgumentException('SharedWith is not a valid circle'); throw new \InvalidArgumentException('SharedWith is not a valid circle');
} }
} elseif ($share->getShareType() === IShare::TYPE_ROOM) { } elseif ($share->getShareType() === IShare::TYPE_ROOM) {
} elseif ($share->getShareType() === IShare::TYPE_DECK) {
} else { } else {
// We can't handle other types yet // We can't handle other types yet
throw new \InvalidArgumentException('unknown share type'); throw new \InvalidArgumentException('unknown share type');
@ -1887,6 +1888,10 @@ class Manager implements IManager {
return true; return true;
} }
public function registerShareProvider(string $shareProviderClass): void {
$this->factory->registerProvider($shareProviderClass);
}
public function getAllShares(): iterable { public function getAllShares(): iterable {
$providers = $this->factory->getAllProviders(); $providers = $this->factory->getAllProviders();

View File

@ -44,6 +44,7 @@ use OCP\EventDispatcher\IEventDispatcher;
use OCP\IServerContainer; use OCP\IServerContainer;
use OCP\Share\IProviderFactory; use OCP\Share\IProviderFactory;
use OCP\Share\IShare; use OCP\Share\IShare;
use OCP\Share\IShareProvider;
/** /**
* Class ProviderFactory * Class ProviderFactory
@ -67,6 +68,10 @@ class ProviderFactory implements IProviderFactory {
/** @var \OCA\Talk\Share\RoomShareProvider */ /** @var \OCA\Talk\Share\RoomShareProvider */
private $roomShareProvider = null; private $roomShareProvider = null;
private $registeredShareProviders = [];
private $shareProviders = [];
/** /**
* IProviderFactory constructor. * IProviderFactory constructor.
* *
@ -76,6 +81,10 @@ class ProviderFactory implements IProviderFactory {
$this->serverContainer = $serverContainer; $this->serverContainer = $serverContainer;
} }
public function registerProvider(string $shareProviderClass): void {
$this->registeredShareProviders[] = $shareProviderClass;
}
/** /**
* Create the default share provider. * Create the default share provider.
* *
@ -257,6 +266,10 @@ class ProviderFactory implements IProviderFactory {
*/ */
public function getProvider($id) { public function getProvider($id) {
$provider = null; $provider = null;
if (isset($this->shareProviders[$id])) {
return $this->shareProviders[$id];
}
if ($id === 'ocinternal') { if ($id === 'ocinternal') {
$provider = $this->defaultShareProvider(); $provider = $this->defaultShareProvider();
} elseif ($id === 'ocFederatedSharing') { } elseif ($id === 'ocFederatedSharing') {
@ -269,6 +282,16 @@ class ProviderFactory implements IProviderFactory {
$provider = $this->getRoomShareProvider(); $provider = $this->getRoomShareProvider();
} }
foreach ($this->registeredShareProviders as $shareProvider) {
/** @var IShareProvider $instance */
$instance = $this->serverContainer->get($shareProvider);
$this->shareProviders[$instance->identifier()] = $instance;
}
if (isset($this->shareProviders[$id])) {
$provider = $this->shareProviders[$id];
}
if ($provider === null) { if ($provider === null) {
throw new ProviderException('No provider with id .' . $id . ' found.'); throw new ProviderException('No provider with id .' . $id . ' found.');
} }
@ -295,6 +318,8 @@ class ProviderFactory implements IProviderFactory {
$provider = $this->getShareByCircleProvider(); $provider = $this->getShareByCircleProvider();
} elseif ($shareType === IShare::TYPE_ROOM) { } elseif ($shareType === IShare::TYPE_ROOM) {
$provider = $this->getRoomShareProvider(); $provider = $this->getRoomShareProvider();
} elseif ($shareType === IShare::TYPE_DECK) {
$provider = $this->getProvider('deck');
} }
@ -320,6 +345,17 @@ class ProviderFactory implements IProviderFactory {
$shares[] = $roomShare; $shares[] = $roomShare;
} }
foreach ($this->registeredShareProviders as $shareProvider) {
/** @var IShareProvider $instance */
$instance = $this->serverContainer->get($shareProvider);
if (!isset($this->shareProviders[$instance->identifier()])) {
$this->shareProviders[$instance->identifier()] = $instance;
}
$shares[] = $this->shareProviders[$instance->identifier()];
}
return $shares; return $shares;
} }
} }

View File

@ -416,6 +416,12 @@ interface IManager {
*/ */
public function shareProviderExists($shareType); public function shareProviderExists($shareType);
/**
* @param string $shareProviderClass
* @since 21.0.0
*/
public function registerShareProvider(string $shareProviderClass): void;
/** /**
* @Internal * @Internal
* *

View File

@ -53,4 +53,10 @@ interface IProviderFactory {
* @since 11.0.0 * @since 11.0.0
*/ */
public function getAllProviders(); public function getAllProviders();
/**
* @since 21.0.0
* @param string $shareProvier
*/
public function registerProvider(string $shareProvier): void;
} }

View File

@ -105,6 +105,17 @@ interface IShare {
*/ */
// const TYPE_USERROOM = 11; // const TYPE_USERROOM = 11;
/**
* @since 21.0.0
*/
public const TYPE_DECK = 12;
/**
* @internal
* @since 21.0.0
*/
public const TYPE_DECK_USER = 13;
/** /**
* @since 18.0.0 * @since 18.0.0
*/ */

View File

@ -85,5 +85,12 @@
<file name="core/register_command.php" /> <file name="core/register_command.php" />
</errorLevel> </errorLevel>
</UndefinedGlobalVariable> </UndefinedGlobalVariable>
<UndefinedDocblockClass>
<errorLevel type="suppress">
<!-- Helper classes for sharing API integration from other apps -->
<referencedClass name="OCA\Deck\Sharing\ShareAPIHelper" />
<referencedClass name="OCA\Talk\Share\Helper\DeletedShareAPIController" />
</errorLevel>
</UndefinedDocblockClass>
</issueHandlers> </issueHandlers>
</psalm> </psalm>

View File

@ -4362,6 +4362,9 @@ class DummyFactory implements IProviderFactory {
public function getAllProviders() { public function getAllProviders() {
return [$this->provider]; return [$this->provider];
} }
public function registerProvider(string $shareProvier): void {
}
} }
class DummyFactory2 extends DummyFactory { class DummyFactory2 extends DummyFactory {
@ -4378,4 +4381,7 @@ class DummyFactory2 extends DummyFactory {
public function getAllProviders() { public function getAllProviders() {
return [$this->provider, $this->provider2]; return [$this->provider, $this->provider2];
} }
public function registerProvider(string $shareProvier): void {
}
} }