@@ -34,172 +34,172 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | interface IShareProvider { |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Return the identifier of this provider. |
|
| 39 | - * |
|
| 40 | - * @return string Containing only [a-zA-Z0-9] |
|
| 41 | - * @since 9.0.0 |
|
| 42 | - */ |
|
| 43 | - public function identifier(); |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Create a share |
|
| 47 | - * |
|
| 48 | - * @param \OCP\Share\IShare $share |
|
| 49 | - * @return \OCP\Share\IShare The share object |
|
| 50 | - * @since 9.0.0 |
|
| 51 | - */ |
|
| 52 | - public function create(\OCP\Share\IShare $share); |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Update a share |
|
| 56 | - * |
|
| 57 | - * @param \OCP\Share\IShare $share |
|
| 58 | - * @return \OCP\Share\IShare The share object |
|
| 59 | - * @since 9.0.0 |
|
| 60 | - */ |
|
| 61 | - public function update(\OCP\Share\IShare $share); |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Delete a share |
|
| 65 | - * |
|
| 66 | - * @param \OCP\Share\IShare $share |
|
| 67 | - * @since 9.0.0 |
|
| 68 | - */ |
|
| 69 | - public function delete(\OCP\Share\IShare $share); |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Unshare a file from self as recipient. |
|
| 73 | - * This may require special handling. If a user unshares a group |
|
| 74 | - * share from their self then the original group share should still exist. |
|
| 75 | - * |
|
| 76 | - * @param \OCP\Share\IShare $share |
|
| 77 | - * @param string $recipient UserId of the recipient |
|
| 78 | - * @since 9.0.0 |
|
| 79 | - */ |
|
| 80 | - public function deleteFromSelf(\OCP\Share\IShare $share, $recipient); |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Move a share as a recipient. |
|
| 84 | - * This is updating the share target. Thus the mount point of the recipient. |
|
| 85 | - * This may require special handling. If a user moves a group share |
|
| 86 | - * the target should only be changed for them. |
|
| 87 | - * |
|
| 88 | - * @param \OCP\Share\IShare $share |
|
| 89 | - * @param string $recipient userId of recipient |
|
| 90 | - * @return \OCP\Share\IShare |
|
| 91 | - * @since 9.0.0 |
|
| 92 | - */ |
|
| 93 | - public function move(\OCP\Share\IShare $share, $recipient); |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Get all shares by the given user in a folder |
|
| 97 | - * |
|
| 98 | - * @param string $userId |
|
| 99 | - * @param Folder $node |
|
| 100 | - * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator |
|
| 101 | - * @return \OCP\Share\IShare[] |
|
| 102 | - * @since 11.0.0 |
|
| 103 | - */ |
|
| 104 | - public function getSharesInFolder($userId, Folder $node, $reshares); |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Get all shares by the given user |
|
| 108 | - * |
|
| 109 | - * @param string $userId |
|
| 110 | - * @param int $shareType |
|
| 111 | - * @param Node|null $node |
|
| 112 | - * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator |
|
| 113 | - * @param int $limit The maximum number of shares to be returned, -1 for all shares |
|
| 114 | - * @param int $offset |
|
| 115 | - * @return \OCP\Share\IShare[] |
|
| 116 | - * @since 9.0.0 |
|
| 117 | - */ |
|
| 118 | - public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset); |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * Get share by id |
|
| 122 | - * |
|
| 123 | - * @param int $id |
|
| 124 | - * @param string|null $recipientId |
|
| 125 | - * @return \OCP\Share\IShare |
|
| 126 | - * @throws ShareNotFound |
|
| 127 | - * @since 9.0.0 |
|
| 128 | - */ |
|
| 129 | - public function getShareById($id, $recipientId = null); |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Get shares for a given path |
|
| 133 | - * |
|
| 134 | - * @param Node $path |
|
| 135 | - * @return \OCP\Share\IShare[] |
|
| 136 | - * @since 9.0.0 |
|
| 137 | - */ |
|
| 138 | - public function getSharesByPath(Node $path); |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Get shared with the given user |
|
| 142 | - * |
|
| 143 | - * @param string $userId get shares where this user is the recipient |
|
| 144 | - * @param int $shareType |
|
| 145 | - * @param Node|null $node |
|
| 146 | - * @param int $limit The max number of entries returned, -1 for all |
|
| 147 | - * @param int $offset |
|
| 148 | - * @return \OCP\Share\IShare[] |
|
| 149 | - * @since 9.0.0 |
|
| 150 | - */ |
|
| 151 | - public function getSharedWith($userId, $shareType, $node, $limit, $offset); |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * Get a share by token |
|
| 155 | - * |
|
| 156 | - * @param string $token |
|
| 157 | - * @return \OCP\Share\IShare |
|
| 158 | - * @throws ShareNotFound |
|
| 159 | - * @since 9.0.0 |
|
| 160 | - */ |
|
| 161 | - public function getShareByToken($token); |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * A user is deleted from the system |
|
| 165 | - * So clean up the relevant shares. |
|
| 166 | - * |
|
| 167 | - * @param string $uid |
|
| 168 | - * @param int $shareType |
|
| 169 | - * @since 9.1.0 |
|
| 170 | - */ |
|
| 171 | - public function userDeleted($uid, $shareType); |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * A group is deleted from the system. |
|
| 175 | - * We have to clean up all shares to this group. |
|
| 176 | - * Providers not handling group shares should just return |
|
| 177 | - * |
|
| 178 | - * @param string $gid |
|
| 179 | - * @since 9.1.0 |
|
| 180 | - */ |
|
| 181 | - public function groupDeleted($gid); |
|
| 182 | - |
|
| 183 | - /** |
|
| 184 | - * A user is deleted from a group |
|
| 185 | - * We have to clean up all the related user specific group shares |
|
| 186 | - * Providers not handling group shares should just return |
|
| 187 | - * |
|
| 188 | - * @param string $uid |
|
| 189 | - * @param string $gid |
|
| 190 | - * @since 9.1.0 |
|
| 191 | - */ |
|
| 192 | - public function userDeletedFromGroup($uid, $gid); |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * Get the access list to the array of provided nodes. |
|
| 196 | - * |
|
| 197 | - * @see IManager::getAccessList() for sample docs |
|
| 198 | - * |
|
| 199 | - * @param Node[] $nodes The list of nodes to get access for |
|
| 200 | - * @param bool $currentAccess If current access is required (like for removed shares that might get revived later) |
|
| 201 | - * @return array |
|
| 202 | - * @since 12 |
|
| 203 | - */ |
|
| 204 | - public function getAccessList($nodes, $currentAccess); |
|
| 37 | + /** |
|
| 38 | + * Return the identifier of this provider. |
|
| 39 | + * |
|
| 40 | + * @return string Containing only [a-zA-Z0-9] |
|
| 41 | + * @since 9.0.0 |
|
| 42 | + */ |
|
| 43 | + public function identifier(); |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Create a share |
|
| 47 | + * |
|
| 48 | + * @param \OCP\Share\IShare $share |
|
| 49 | + * @return \OCP\Share\IShare The share object |
|
| 50 | + * @since 9.0.0 |
|
| 51 | + */ |
|
| 52 | + public function create(\OCP\Share\IShare $share); |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Update a share |
|
| 56 | + * |
|
| 57 | + * @param \OCP\Share\IShare $share |
|
| 58 | + * @return \OCP\Share\IShare The share object |
|
| 59 | + * @since 9.0.0 |
|
| 60 | + */ |
|
| 61 | + public function update(\OCP\Share\IShare $share); |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Delete a share |
|
| 65 | + * |
|
| 66 | + * @param \OCP\Share\IShare $share |
|
| 67 | + * @since 9.0.0 |
|
| 68 | + */ |
|
| 69 | + public function delete(\OCP\Share\IShare $share); |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Unshare a file from self as recipient. |
|
| 73 | + * This may require special handling. If a user unshares a group |
|
| 74 | + * share from their self then the original group share should still exist. |
|
| 75 | + * |
|
| 76 | + * @param \OCP\Share\IShare $share |
|
| 77 | + * @param string $recipient UserId of the recipient |
|
| 78 | + * @since 9.0.0 |
|
| 79 | + */ |
|
| 80 | + public function deleteFromSelf(\OCP\Share\IShare $share, $recipient); |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Move a share as a recipient. |
|
| 84 | + * This is updating the share target. Thus the mount point of the recipient. |
|
| 85 | + * This may require special handling. If a user moves a group share |
|
| 86 | + * the target should only be changed for them. |
|
| 87 | + * |
|
| 88 | + * @param \OCP\Share\IShare $share |
|
| 89 | + * @param string $recipient userId of recipient |
|
| 90 | + * @return \OCP\Share\IShare |
|
| 91 | + * @since 9.0.0 |
|
| 92 | + */ |
|
| 93 | + public function move(\OCP\Share\IShare $share, $recipient); |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Get all shares by the given user in a folder |
|
| 97 | + * |
|
| 98 | + * @param string $userId |
|
| 99 | + * @param Folder $node |
|
| 100 | + * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator |
|
| 101 | + * @return \OCP\Share\IShare[] |
|
| 102 | + * @since 11.0.0 |
|
| 103 | + */ |
|
| 104 | + public function getSharesInFolder($userId, Folder $node, $reshares); |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Get all shares by the given user |
|
| 108 | + * |
|
| 109 | + * @param string $userId |
|
| 110 | + * @param int $shareType |
|
| 111 | + * @param Node|null $node |
|
| 112 | + * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator |
|
| 113 | + * @param int $limit The maximum number of shares to be returned, -1 for all shares |
|
| 114 | + * @param int $offset |
|
| 115 | + * @return \OCP\Share\IShare[] |
|
| 116 | + * @since 9.0.0 |
|
| 117 | + */ |
|
| 118 | + public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset); |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * Get share by id |
|
| 122 | + * |
|
| 123 | + * @param int $id |
|
| 124 | + * @param string|null $recipientId |
|
| 125 | + * @return \OCP\Share\IShare |
|
| 126 | + * @throws ShareNotFound |
|
| 127 | + * @since 9.0.0 |
|
| 128 | + */ |
|
| 129 | + public function getShareById($id, $recipientId = null); |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Get shares for a given path |
|
| 133 | + * |
|
| 134 | + * @param Node $path |
|
| 135 | + * @return \OCP\Share\IShare[] |
|
| 136 | + * @since 9.0.0 |
|
| 137 | + */ |
|
| 138 | + public function getSharesByPath(Node $path); |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Get shared with the given user |
|
| 142 | + * |
|
| 143 | + * @param string $userId get shares where this user is the recipient |
|
| 144 | + * @param int $shareType |
|
| 145 | + * @param Node|null $node |
|
| 146 | + * @param int $limit The max number of entries returned, -1 for all |
|
| 147 | + * @param int $offset |
|
| 148 | + * @return \OCP\Share\IShare[] |
|
| 149 | + * @since 9.0.0 |
|
| 150 | + */ |
|
| 151 | + public function getSharedWith($userId, $shareType, $node, $limit, $offset); |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * Get a share by token |
|
| 155 | + * |
|
| 156 | + * @param string $token |
|
| 157 | + * @return \OCP\Share\IShare |
|
| 158 | + * @throws ShareNotFound |
|
| 159 | + * @since 9.0.0 |
|
| 160 | + */ |
|
| 161 | + public function getShareByToken($token); |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * A user is deleted from the system |
|
| 165 | + * So clean up the relevant shares. |
|
| 166 | + * |
|
| 167 | + * @param string $uid |
|
| 168 | + * @param int $shareType |
|
| 169 | + * @since 9.1.0 |
|
| 170 | + */ |
|
| 171 | + public function userDeleted($uid, $shareType); |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * A group is deleted from the system. |
|
| 175 | + * We have to clean up all shares to this group. |
|
| 176 | + * Providers not handling group shares should just return |
|
| 177 | + * |
|
| 178 | + * @param string $gid |
|
| 179 | + * @since 9.1.0 |
|
| 180 | + */ |
|
| 181 | + public function groupDeleted($gid); |
|
| 182 | + |
|
| 183 | + /** |
|
| 184 | + * A user is deleted from a group |
|
| 185 | + * We have to clean up all the related user specific group shares |
|
| 186 | + * Providers not handling group shares should just return |
|
| 187 | + * |
|
| 188 | + * @param string $uid |
|
| 189 | + * @param string $gid |
|
| 190 | + * @since 9.1.0 |
|
| 191 | + */ |
|
| 192 | + public function userDeletedFromGroup($uid, $gid); |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * Get the access list to the array of provided nodes. |
|
| 196 | + * |
|
| 197 | + * @see IManager::getAccessList() for sample docs |
|
| 198 | + * |
|
| 199 | + * @param Node[] $nodes The list of nodes to get access for |
|
| 200 | + * @param bool $currentAccess If current access is required (like for removed shares that might get revived later) |
|
| 201 | + * @return array |
|
| 202 | + * @since 12 |
|
| 203 | + */ |
|
| 204 | + public function getAccessList($nodes, $currentAccess); |
|
| 205 | 205 | } |
@@ -29,11 +29,11 @@ |
||
| 29 | 29 | $isEnabled = $server->getAppManager()->isEnabledForUser('cloud_federation_api'); |
| 30 | 30 | |
| 31 | 31 | if ($isEnabled) { |
| 32 | - $capabilities = new OCA\CloudFederationAPI\Capabilities($server->getURLGenerator()); |
|
| 33 | - header('Content-Type: application/json'); |
|
| 34 | - echo json_encode($capabilities->getCapabilities()['ocm']); |
|
| 32 | + $capabilities = new OCA\CloudFederationAPI\Capabilities($server->getURLGenerator()); |
|
| 33 | + header('Content-Type: application/json'); |
|
| 34 | + echo json_encode($capabilities->getCapabilities()['ocm']); |
|
| 35 | 35 | } else { |
| 36 | - header($_SERVER["SERVER_PROTOCOL"]." 501 Not Implemented", true, 501); |
|
| 37 | - exit("501 Not Implemented"); |
|
| 36 | + header($_SERVER["SERVER_PROTOCOL"]." 501 Not Implemented", true, 501); |
|
| 37 | + exit("501 Not Implemented"); |
|
| 38 | 38 | } |
| 39 | 39 | |
@@ -28,10 +28,10 @@ |
||
| 28 | 28 | |
| 29 | 29 | class Application extends App { |
| 30 | 30 | |
| 31 | - public function __construct() { |
|
| 32 | - parent::__construct('cloud_federation_api'); |
|
| 31 | + public function __construct() { |
|
| 32 | + parent::__construct('cloud_federation_api'); |
|
| 33 | 33 | |
| 34 | - $container = $this->getContainer(); |
|
| 35 | - $container->registerCapability(Capabilities::class); |
|
| 36 | - } |
|
| 34 | + $container = $this->getContainer(); |
|
| 35 | + $container->registerCapability(Capabilities::class); |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -36,47 +36,47 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | $application = new Application(); |
| 38 | 38 | $application->registerRoutes($this, [ |
| 39 | - 'routes' => [ |
|
| 40 | - ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
| 41 | - ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
| 42 | - ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
| 43 | - ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
| 44 | - ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
| 45 | - ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
| 46 | - ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
| 47 | - ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
| 48 | - ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
| 49 | - ['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'], |
|
| 50 | - ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
| 51 | - ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
| 52 | - ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
| 53 | - ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
| 54 | - ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'], |
|
| 55 | - ['name' => 'ClientFlowLogin#redirectPage', 'url' => '/login/flow/redirect', 'verb' => 'GET'], |
|
| 56 | - ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'], |
|
| 57 | - ['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'], |
|
| 58 | - ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
| 59 | - ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
| 60 | - ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
| 61 | - ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
| 62 | - ['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'], |
|
| 63 | - ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
| 64 | - ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
| 65 | - ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'], |
|
| 66 | - ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'], |
|
| 67 | - ['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'], |
|
| 68 | - ['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'], |
|
| 69 | - ['name' => 'Search#search', 'url' => '/core/search', 'verb' => 'GET'], |
|
| 70 | - ], |
|
| 71 | - 'ocs' => [ |
|
| 72 | - ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
| 73 | - ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
| 74 | - ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
| 75 | - ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
| 76 | - ['root' => '/core', 'name' => 'Navigation#getAppsNavigation', 'url' => '/navigation/apps', 'verb' => 'GET'], |
|
| 77 | - ['root' => '/core', 'name' => 'Navigation#getSettingsNavigation', 'url' => '/navigation/settings', 'verb' => 'GET'], |
|
| 78 | - ['root' => '/core', 'name' => 'AutoComplete#get', 'url' => '/autocomplete/get', 'verb' => 'GET'], |
|
| 79 | - ], |
|
| 39 | + 'routes' => [ |
|
| 40 | + ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
| 41 | + ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
| 42 | + ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
| 43 | + ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
| 44 | + ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
| 45 | + ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
| 46 | + ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
| 47 | + ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
| 48 | + ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
| 49 | + ['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'], |
|
| 50 | + ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
| 51 | + ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
| 52 | + ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
| 53 | + ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
| 54 | + ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'], |
|
| 55 | + ['name' => 'ClientFlowLogin#redirectPage', 'url' => '/login/flow/redirect', 'verb' => 'GET'], |
|
| 56 | + ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'], |
|
| 57 | + ['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'], |
|
| 58 | + ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
| 59 | + ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
| 60 | + ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
| 61 | + ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
| 62 | + ['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'], |
|
| 63 | + ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
| 64 | + ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
| 65 | + ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'], |
|
| 66 | + ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'], |
|
| 67 | + ['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'], |
|
| 68 | + ['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'], |
|
| 69 | + ['name' => 'Search#search', 'url' => '/core/search', 'verb' => 'GET'], |
|
| 70 | + ], |
|
| 71 | + 'ocs' => [ |
|
| 72 | + ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
| 73 | + ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
| 74 | + ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
| 75 | + ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
| 76 | + ['root' => '/core', 'name' => 'Navigation#getAppsNavigation', 'url' => '/navigation/apps', 'verb' => 'GET'], |
|
| 77 | + ['root' => '/core', 'name' => 'Navigation#getSettingsNavigation', 'url' => '/navigation/settings', 'verb' => 'GET'], |
|
| 78 | + ['root' => '/core', 'name' => 'AutoComplete#get', 'url' => '/autocomplete/get', 'verb' => 'GET'], |
|
| 79 | + ], |
|
| 80 | 80 | ]); |
| 81 | 81 | |
| 82 | 82 | // Post installation check |
@@ -85,12 +85,12 @@ discard block |
||
| 85 | 85 | // Core ajax actions |
| 86 | 86 | // Routing |
| 87 | 87 | $this->create('core_ajax_update', '/core/ajax/update.php') |
| 88 | - ->actionInclude('core/ajax/update.php'); |
|
| 88 | + ->actionInclude('core/ajax/update.php'); |
|
| 89 | 89 | |
| 90 | 90 | // File routes |
| 91 | 91 | $this->create('files.viewcontroller.showFile', '/f/{fileid}')->action(function($urlParams) { |
| 92 | - $app = new \OCA\Files\AppInfo\Application($urlParams); |
|
| 93 | - $app->dispatch('ViewController', 'index'); |
|
| 92 | + $app = new \OCA\Files\AppInfo\Application($urlParams); |
|
| 93 | + $app->dispatch('ViewController', 'index'); |
|
| 94 | 94 | }); |
| 95 | 95 | |
| 96 | 96 | // Call routes |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | * @suppress PhanUndeclaredClassMethod |
| 100 | 100 | */ |
| 101 | 101 | $this->create('spreed.pagecontroller.showCall', '/call/{token}')->action(function($urlParams) { |
| 102 | - if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) { |
|
| 103 | - $app = new \OCA\Spreed\AppInfo\Application($urlParams); |
|
| 104 | - $app->dispatch('PageController', 'index'); |
|
| 105 | - } else { |
|
| 106 | - throw new \OC\HintException('App spreed is not enabled'); |
|
| 107 | - } |
|
| 102 | + if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) { |
|
| 103 | + $app = new \OCA\Spreed\AppInfo\Application($urlParams); |
|
| 104 | + $app->dispatch('PageController', 'index'); |
|
| 105 | + } else { |
|
| 106 | + throw new \OC\HintException('App spreed is not enabled'); |
|
| 107 | + } |
|
| 108 | 108 | }); |
| 109 | 109 | |
| 110 | 110 | // OCM routes |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | * @suppress PhanUndeclaredClassMethod |
| 114 | 114 | */ |
| 115 | 115 | $this->create('cloud_federation_api.requesthandlercontroller.addShare', '/ocm/shares')->post()->action(function($urlParams) { |
| 116 | - if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) { |
|
| 117 | - $app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams); |
|
| 118 | - $app->dispatch('RequestHandlerController', 'addShare'); |
|
| 119 | - } else { |
|
| 120 | - throw new \OC\HintException('Cloud Federation API not enabled'); |
|
| 121 | - } |
|
| 116 | + if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) { |
|
| 117 | + $app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams); |
|
| 118 | + $app->dispatch('RequestHandlerController', 'addShare'); |
|
| 119 | + } else { |
|
| 120 | + throw new \OC\HintException('Cloud Federation API not enabled'); |
|
| 121 | + } |
|
| 122 | 122 | }); |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -126,53 +126,53 @@ discard block |
||
| 126 | 126 | * @suppress PhanUndeclaredClassMethod |
| 127 | 127 | */ |
| 128 | 128 | $this->create('cloud_federation_api.requesthandlercontroller.receiveNotification', '/ocm/notifications')->post()->action(function($urlParams) { |
| 129 | - if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) { |
|
| 130 | - $app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams); |
|
| 131 | - $app->dispatch('RequestHandlerController', 'receiveNotification'); |
|
| 132 | - } else { |
|
| 133 | - throw new \OC\HintException('Cloud Federation API not enabled'); |
|
| 134 | - } |
|
| 129 | + if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) { |
|
| 130 | + $app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams); |
|
| 131 | + $app->dispatch('RequestHandlerController', 'receiveNotification'); |
|
| 132 | + } else { |
|
| 133 | + throw new \OC\HintException('Cloud Federation API not enabled'); |
|
| 134 | + } |
|
| 135 | 135 | }); |
| 136 | 136 | |
| 137 | 137 | |
| 138 | 138 | // Sharing routes |
| 139 | 139 | $this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(function($urlParams) { |
| 140 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 141 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 142 | - $app->dispatch('ShareController', 'showShare'); |
|
| 143 | - } else { |
|
| 144 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
| 145 | - } |
|
| 140 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 141 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 142 | + $app->dispatch('ShareController', 'showShare'); |
|
| 143 | + } else { |
|
| 144 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
| 145 | + } |
|
| 146 | 146 | }); |
| 147 | 147 | $this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenticate/{redirect}')->post()->action(function($urlParams) { |
| 148 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 149 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 150 | - $app->dispatch('ShareController', 'authenticate'); |
|
| 151 | - } else { |
|
| 152 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
| 153 | - } |
|
| 148 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 149 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 150 | + $app->dispatch('ShareController', 'authenticate'); |
|
| 151 | + } else { |
|
| 152 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
| 153 | + } |
|
| 154 | 154 | }); |
| 155 | 155 | $this->create('files_sharing.sharecontroller.showAuthenticate', '/s/{token}/authenticate/{redirect}')->get()->action(function($urlParams) { |
| 156 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 157 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 158 | - $app->dispatch('ShareController', 'showAuthenticate'); |
|
| 159 | - } else { |
|
| 160 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
| 161 | - } |
|
| 156 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 157 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 158 | + $app->dispatch('ShareController', 'showAuthenticate'); |
|
| 159 | + } else { |
|
| 160 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
| 161 | + } |
|
| 162 | 162 | }); |
| 163 | 163 | $this->create('files_sharing.sharecontroller.downloadShare', '/s/{token}/download')->get()->action(function($urlParams) { |
| 164 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 165 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 166 | - $app->dispatch('ShareController', 'downloadShare'); |
|
| 167 | - } else { |
|
| 168 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
| 169 | - } |
|
| 164 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 165 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 166 | + $app->dispatch('ShareController', 'downloadShare'); |
|
| 167 | + } else { |
|
| 168 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
| 169 | + } |
|
| 170 | 170 | }); |
| 171 | 171 | $this->create('files_sharing.publicpreview.directLink', '/s/{token}/preview')->get()->action(function($urlParams) { |
| 172 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 173 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 174 | - $app->dispatch('PublicPreviewController', 'directLink'); |
|
| 175 | - } else { |
|
| 176 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
| 177 | - } |
|
| 172 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 173 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 174 | + $app->dispatch('PublicPreviewController', 'directLink'); |
|
| 175 | + } else { |
|
| 176 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
| 177 | + } |
|
| 178 | 178 | }); |
@@ -45,105 +45,105 @@ |
||
| 45 | 45 | */ |
| 46 | 46 | class RetryJob extends Job { |
| 47 | 47 | |
| 48 | - /** @var bool */ |
|
| 49 | - private $retainJob = true; |
|
| 50 | - |
|
| 51 | - /** @var Notifications */ |
|
| 52 | - private $notifications; |
|
| 53 | - |
|
| 54 | - /** @var int max number of attempts to send the request */ |
|
| 55 | - private $maxTry = 20; |
|
| 56 | - |
|
| 57 | - /** @var int how much time should be between two tries (10 minutes) */ |
|
| 58 | - private $interval = 600; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * UnShare constructor. |
|
| 62 | - * |
|
| 63 | - * @param Notifications $notifications |
|
| 64 | - */ |
|
| 65 | - public function __construct(Notifications $notifications = null) { |
|
| 66 | - if ($notifications) { |
|
| 67 | - $this->notifications = $notifications; |
|
| 68 | - } else { |
|
| 69 | - $addressHandler = new AddressHandler( |
|
| 70 | - \OC::$server->getURLGenerator(), |
|
| 71 | - \OC::$server->getL10N('federatedfilesharing'), |
|
| 72 | - \OC::$server->getCloudIdManager() |
|
| 73 | - ); |
|
| 74 | - $this->notifications = new Notifications( |
|
| 75 | - $addressHandler, |
|
| 76 | - \OC::$server->getHTTPClientService(), |
|
| 77 | - \OC::$server->query(\OCP\OCS\IDiscoveryService::class), |
|
| 78 | - \OC::$server->getJobList(), |
|
| 79 | - \OC::$server->getCloudFederationProviderManager(), |
|
| 80 | - \OC::$server->getCloudFederationFactory() |
|
| 81 | - ); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * run the job, then remove it from the jobList |
|
| 88 | - * |
|
| 89 | - * @param JobList $jobList |
|
| 90 | - * @param ILogger|null $logger |
|
| 91 | - */ |
|
| 92 | - public function execute($jobList, ILogger $logger = null) { |
|
| 93 | - |
|
| 94 | - if ($this->shouldRun($this->argument)) { |
|
| 95 | - parent::execute($jobList, $logger); |
|
| 96 | - $jobList->remove($this, $this->argument); |
|
| 97 | - if ($this->retainJob) { |
|
| 98 | - $this->reAddJob($jobList, $this->argument); |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - protected function run($argument) { |
|
| 104 | - $remote = $argument['remote']; |
|
| 105 | - $remoteId = $argument['remoteId']; |
|
| 106 | - $token = $argument['token']; |
|
| 107 | - $action = $argument['action']; |
|
| 108 | - $data = json_decode($argument['data'], true); |
|
| 109 | - $try = (int)$argument['try'] + 1; |
|
| 110 | - |
|
| 111 | - $result = $this->notifications->sendUpdateToRemote($remote, $remoteId, $token, $action, $data, $try); |
|
| 112 | - |
|
| 113 | - if ($result === true || $try > $this->maxTry) { |
|
| 114 | - $this->retainJob = false; |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * re-add background job with new arguments |
|
| 120 | - * |
|
| 121 | - * @param IJobList $jobList |
|
| 122 | - * @param array $argument |
|
| 123 | - */ |
|
| 124 | - protected function reAddJob(IJobList $jobList, array $argument) { |
|
| 125 | - $jobList->add(RetryJob::class, |
|
| 126 | - [ |
|
| 127 | - 'remote' => $argument['remote'], |
|
| 128 | - 'remoteId' => $argument['remoteId'], |
|
| 129 | - 'token' => $argument['token'], |
|
| 130 | - 'data' => $argument['data'], |
|
| 131 | - 'action' => $argument['action'], |
|
| 132 | - 'try' => (int)$argument['try'] + 1, |
|
| 133 | - 'lastRun' => time() |
|
| 134 | - ] |
|
| 135 | - ); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * test if it is time for the next run |
|
| 140 | - * |
|
| 141 | - * @param array $argument |
|
| 142 | - * @return bool |
|
| 143 | - */ |
|
| 144 | - protected function shouldRun(array $argument) { |
|
| 145 | - $lastRun = (int)$argument['lastRun']; |
|
| 146 | - return ((time() - $lastRun) > $this->interval); |
|
| 147 | - } |
|
| 48 | + /** @var bool */ |
|
| 49 | + private $retainJob = true; |
|
| 50 | + |
|
| 51 | + /** @var Notifications */ |
|
| 52 | + private $notifications; |
|
| 53 | + |
|
| 54 | + /** @var int max number of attempts to send the request */ |
|
| 55 | + private $maxTry = 20; |
|
| 56 | + |
|
| 57 | + /** @var int how much time should be between two tries (10 minutes) */ |
|
| 58 | + private $interval = 600; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * UnShare constructor. |
|
| 62 | + * |
|
| 63 | + * @param Notifications $notifications |
|
| 64 | + */ |
|
| 65 | + public function __construct(Notifications $notifications = null) { |
|
| 66 | + if ($notifications) { |
|
| 67 | + $this->notifications = $notifications; |
|
| 68 | + } else { |
|
| 69 | + $addressHandler = new AddressHandler( |
|
| 70 | + \OC::$server->getURLGenerator(), |
|
| 71 | + \OC::$server->getL10N('federatedfilesharing'), |
|
| 72 | + \OC::$server->getCloudIdManager() |
|
| 73 | + ); |
|
| 74 | + $this->notifications = new Notifications( |
|
| 75 | + $addressHandler, |
|
| 76 | + \OC::$server->getHTTPClientService(), |
|
| 77 | + \OC::$server->query(\OCP\OCS\IDiscoveryService::class), |
|
| 78 | + \OC::$server->getJobList(), |
|
| 79 | + \OC::$server->getCloudFederationProviderManager(), |
|
| 80 | + \OC::$server->getCloudFederationFactory() |
|
| 81 | + ); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * run the job, then remove it from the jobList |
|
| 88 | + * |
|
| 89 | + * @param JobList $jobList |
|
| 90 | + * @param ILogger|null $logger |
|
| 91 | + */ |
|
| 92 | + public function execute($jobList, ILogger $logger = null) { |
|
| 93 | + |
|
| 94 | + if ($this->shouldRun($this->argument)) { |
|
| 95 | + parent::execute($jobList, $logger); |
|
| 96 | + $jobList->remove($this, $this->argument); |
|
| 97 | + if ($this->retainJob) { |
|
| 98 | + $this->reAddJob($jobList, $this->argument); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + protected function run($argument) { |
|
| 104 | + $remote = $argument['remote']; |
|
| 105 | + $remoteId = $argument['remoteId']; |
|
| 106 | + $token = $argument['token']; |
|
| 107 | + $action = $argument['action']; |
|
| 108 | + $data = json_decode($argument['data'], true); |
|
| 109 | + $try = (int)$argument['try'] + 1; |
|
| 110 | + |
|
| 111 | + $result = $this->notifications->sendUpdateToRemote($remote, $remoteId, $token, $action, $data, $try); |
|
| 112 | + |
|
| 113 | + if ($result === true || $try > $this->maxTry) { |
|
| 114 | + $this->retainJob = false; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * re-add background job with new arguments |
|
| 120 | + * |
|
| 121 | + * @param IJobList $jobList |
|
| 122 | + * @param array $argument |
|
| 123 | + */ |
|
| 124 | + protected function reAddJob(IJobList $jobList, array $argument) { |
|
| 125 | + $jobList->add(RetryJob::class, |
|
| 126 | + [ |
|
| 127 | + 'remote' => $argument['remote'], |
|
| 128 | + 'remoteId' => $argument['remoteId'], |
|
| 129 | + 'token' => $argument['token'], |
|
| 130 | + 'data' => $argument['data'], |
|
| 131 | + 'action' => $argument['action'], |
|
| 132 | + 'try' => (int)$argument['try'] + 1, |
|
| 133 | + 'lastRun' => time() |
|
| 134 | + ] |
|
| 135 | + ); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * test if it is time for the next run |
|
| 140 | + * |
|
| 141 | + * @param array $argument |
|
| 142 | + * @return bool |
|
| 143 | + */ |
|
| 144 | + protected function shouldRun(array $argument) { |
|
| 145 | + $lastRun = (int)$argument['lastRun']; |
|
| 146 | + return ((time() - $lastRun) > $this->interval); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | 149 | } |
@@ -27,37 +27,37 @@ |
||
| 27 | 27 | |
| 28 | 28 | class CloudFederationFactory implements ICloudFederationFactory { |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * get a CloudFederationShare Object to prepare a share you want to send |
|
| 32 | - * |
|
| 33 | - * @param string $shareWith |
|
| 34 | - * @param string $name resource name (e.g. document.odt) |
|
| 35 | - * @param string $description share description (optional) |
|
| 36 | - * @param string $providerId resource UID on the provider side |
|
| 37 | - * @param string $owner provider specific UID of the user who owns the resource |
|
| 38 | - * @param string $ownerDisplayName display name of the user who shared the item |
|
| 39 | - * @param string $sharedBy provider specific UID of the user who shared the resource |
|
| 40 | - * @param string $sharedByDisplayName display name of the user who shared the resource |
|
| 41 | - * @param string $sharedSecret used to authenticate requests across servers |
|
| 42 | - * @param string $shareType ('group' or 'user' share) |
|
| 43 | - * @param $resourceType ('file', 'calendar',...) |
|
| 44 | - * @return ICloudFederationShare |
|
| 45 | - * |
|
| 46 | - * @since 14.0.0 |
|
| 47 | - */ |
|
| 48 | - public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $sharedSecret, $shareType, $resourceType) { |
|
| 49 | - return new CloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $shareType, $resourceType, $sharedSecret); |
|
| 50 | - } |
|
| 30 | + /** |
|
| 31 | + * get a CloudFederationShare Object to prepare a share you want to send |
|
| 32 | + * |
|
| 33 | + * @param string $shareWith |
|
| 34 | + * @param string $name resource name (e.g. document.odt) |
|
| 35 | + * @param string $description share description (optional) |
|
| 36 | + * @param string $providerId resource UID on the provider side |
|
| 37 | + * @param string $owner provider specific UID of the user who owns the resource |
|
| 38 | + * @param string $ownerDisplayName display name of the user who shared the item |
|
| 39 | + * @param string $sharedBy provider specific UID of the user who shared the resource |
|
| 40 | + * @param string $sharedByDisplayName display name of the user who shared the resource |
|
| 41 | + * @param string $sharedSecret used to authenticate requests across servers |
|
| 42 | + * @param string $shareType ('group' or 'user' share) |
|
| 43 | + * @param $resourceType ('file', 'calendar',...) |
|
| 44 | + * @return ICloudFederationShare |
|
| 45 | + * |
|
| 46 | + * @since 14.0.0 |
|
| 47 | + */ |
|
| 48 | + public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $sharedSecret, $shareType, $resourceType) { |
|
| 49 | + return new CloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $shareType, $resourceType, $sharedSecret); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * get a Cloud FederationNotification object to prepare a notification you |
|
| 54 | - * want to send |
|
| 55 | - * |
|
| 56 | - * @return ICloudFederationNotification |
|
| 57 | - * |
|
| 58 | - * @since 14.0.0 |
|
| 59 | - */ |
|
| 60 | - public function getCloudFederationNotification() { |
|
| 61 | - return new CloudFederationNotification(); |
|
| 62 | - } |
|
| 52 | + /** |
|
| 53 | + * get a Cloud FederationNotification object to prepare a notification you |
|
| 54 | + * want to send |
|
| 55 | + * |
|
| 56 | + * @return ICloudFederationNotification |
|
| 57 | + * |
|
| 58 | + * @since 14.0.0 |
|
| 59 | + */ |
|
| 60 | + public function getCloudFederationNotification() { |
|
| 61 | + return new CloudFederationNotification(); |
|
| 62 | + } |
|
| 63 | 63 | } |
@@ -28,37 +28,37 @@ |
||
| 28 | 28 | |
| 29 | 29 | class Capabilities implements ICapability { |
| 30 | 30 | |
| 31 | - /** @var IURLGenerator */ |
|
| 32 | - private $urlGenerator; |
|
| 31 | + /** @var IURLGenerator */ |
|
| 32 | + private $urlGenerator; |
|
| 33 | 33 | |
| 34 | - public function __construct(IURLGenerator $urlGenerator) { |
|
| 35 | - $this->urlGenerator = $urlGenerator; |
|
| 36 | - } |
|
| 34 | + public function __construct(IURLGenerator $urlGenerator) { |
|
| 35 | + $this->urlGenerator = $urlGenerator; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Function an app uses to return the capabilities |
|
| 40 | - * |
|
| 41 | - * @return array Array containing the apps capabilities |
|
| 42 | - * @since 8.2.0 |
|
| 43 | - */ |
|
| 44 | - public function getCapabilities() { |
|
| 45 | - $url = $this->urlGenerator->linkToRouteAbsolute('cloud_federation_api.requesthandlercontroller.addShare'); |
|
| 46 | - $capabilities = ['ocm' => |
|
| 47 | - [ |
|
| 48 | - 'enabled' => true, |
|
| 49 | - 'apiVersion' => '1.0-proposal1', |
|
| 50 | - 'endPoint' => substr($url, 0, strrpos($url, '/')), |
|
| 51 | - 'shareTypes' => [ |
|
| 52 | - [ |
|
| 53 | - 'name' => 'file', |
|
| 54 | - 'protocols' => [ |
|
| 55 | - 'webdav' => '/public.php/webdav/', |
|
| 56 | - ] |
|
| 57 | - ], |
|
| 58 | - ] |
|
| 59 | - ] |
|
| 60 | - ]; |
|
| 38 | + /** |
|
| 39 | + * Function an app uses to return the capabilities |
|
| 40 | + * |
|
| 41 | + * @return array Array containing the apps capabilities |
|
| 42 | + * @since 8.2.0 |
|
| 43 | + */ |
|
| 44 | + public function getCapabilities() { |
|
| 45 | + $url = $this->urlGenerator->linkToRouteAbsolute('cloud_federation_api.requesthandlercontroller.addShare'); |
|
| 46 | + $capabilities = ['ocm' => |
|
| 47 | + [ |
|
| 48 | + 'enabled' => true, |
|
| 49 | + 'apiVersion' => '1.0-proposal1', |
|
| 50 | + 'endPoint' => substr($url, 0, strrpos($url, '/')), |
|
| 51 | + 'shareTypes' => [ |
|
| 52 | + [ |
|
| 53 | + 'name' => 'file', |
|
| 54 | + 'protocols' => [ |
|
| 55 | + 'webdav' => '/public.php/webdav/', |
|
| 56 | + ] |
|
| 57 | + ], |
|
| 58 | + ] |
|
| 59 | + ] |
|
| 60 | + ]; |
|
| 61 | 61 | |
| 62 | - return $capabilities; |
|
| 63 | - } |
|
| 62 | + return $capabilities; |
|
| 63 | + } |
|
| 64 | 64 | } |
@@ -450,7 +450,7 @@ |
||
| 450 | 450 | /** |
| 451 | 451 | * translate Nextcloud permissions to OCM Permissions |
| 452 | 452 | * |
| 453 | - * @param $ncPermissions |
|
| 453 | + * @param integer $ncPermissions |
|
| 454 | 454 | * @return array |
| 455 | 455 | */ |
| 456 | 456 | protected function ncPermissions2ocmPermissions($ncPermissions) { |
@@ -52,431 +52,431 @@ |
||
| 52 | 52 | |
| 53 | 53 | class RequestHandlerController extends OCSController { |
| 54 | 54 | |
| 55 | - /** @var FederatedShareProvider */ |
|
| 56 | - private $federatedShareProvider; |
|
| 57 | - |
|
| 58 | - /** @var IDBConnection */ |
|
| 59 | - private $connection; |
|
| 60 | - |
|
| 61 | - /** @var Share\IManager */ |
|
| 62 | - private $shareManager; |
|
| 63 | - |
|
| 64 | - /** @var Notifications */ |
|
| 65 | - private $notifications; |
|
| 66 | - |
|
| 67 | - /** @var AddressHandler */ |
|
| 68 | - private $addressHandler; |
|
| 69 | - |
|
| 70 | - /** @var IUserManager */ |
|
| 71 | - private $userManager; |
|
| 72 | - |
|
| 73 | - /** @var string */ |
|
| 74 | - private $shareTable = 'share'; |
|
| 75 | - |
|
| 76 | - /** @var ICloudIdManager */ |
|
| 77 | - private $cloudIdManager; |
|
| 78 | - |
|
| 79 | - /** @var ILogger */ |
|
| 80 | - private $logger; |
|
| 81 | - |
|
| 82 | - /** @var ICloudFederationFactory */ |
|
| 83 | - private $cloudFederationFactory; |
|
| 84 | - |
|
| 85 | - /** @var ICloudFederationProviderManager */ |
|
| 86 | - private $cloudFederationProviderManager; |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Server2Server constructor. |
|
| 90 | - * |
|
| 91 | - * @param string $appName |
|
| 92 | - * @param IRequest $request |
|
| 93 | - * @param FederatedShareProvider $federatedShareProvider |
|
| 94 | - * @param IDBConnection $connection |
|
| 95 | - * @param Share\IManager $shareManager |
|
| 96 | - * @param Notifications $notifications |
|
| 97 | - * @param AddressHandler $addressHandler |
|
| 98 | - * @param IUserManager $userManager |
|
| 99 | - * @param ICloudIdManager $cloudIdManager |
|
| 100 | - * @param ILogger $logger |
|
| 101 | - * @param ICloudFederationFactory $cloudFederationFactory |
|
| 102 | - * @param ICloudFederationProviderManager $cloudFederationProviderManager |
|
| 103 | - */ |
|
| 104 | - public function __construct($appName, |
|
| 105 | - IRequest $request, |
|
| 106 | - FederatedShareProvider $federatedShareProvider, |
|
| 107 | - IDBConnection $connection, |
|
| 108 | - Share\IManager $shareManager, |
|
| 109 | - Notifications $notifications, |
|
| 110 | - AddressHandler $addressHandler, |
|
| 111 | - IUserManager $userManager, |
|
| 112 | - ICloudIdManager $cloudIdManager, |
|
| 113 | - ILogger $logger, |
|
| 114 | - ICloudFederationFactory $cloudFederationFactory, |
|
| 115 | - ICloudFederationProviderManager $cloudFederationProviderManager |
|
| 116 | - ) { |
|
| 117 | - parent::__construct($appName, $request); |
|
| 118 | - |
|
| 119 | - $this->federatedShareProvider = $federatedShareProvider; |
|
| 120 | - $this->connection = $connection; |
|
| 121 | - $this->shareManager = $shareManager; |
|
| 122 | - $this->notifications = $notifications; |
|
| 123 | - $this->addressHandler = $addressHandler; |
|
| 124 | - $this->userManager = $userManager; |
|
| 125 | - $this->cloudIdManager = $cloudIdManager; |
|
| 126 | - $this->logger = $logger; |
|
| 127 | - $this->cloudFederationFactory = $cloudFederationFactory; |
|
| 128 | - $this->cloudFederationProviderManager = $cloudFederationProviderManager; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @NoCSRFRequired |
|
| 133 | - * @PublicPage |
|
| 134 | - * |
|
| 135 | - * create a new share |
|
| 136 | - * |
|
| 137 | - * @return Http\DataResponse |
|
| 138 | - * @throws OCSException |
|
| 139 | - */ |
|
| 140 | - public function createShare() { |
|
| 141 | - |
|
| 142 | - $remote = isset($_POST['remote']) ? $_POST['remote'] : null; |
|
| 143 | - $token = isset($_POST['token']) ? $_POST['token'] : null; |
|
| 144 | - $name = isset($_POST['name']) ? $_POST['name'] : null; |
|
| 145 | - $owner = isset($_POST['owner']) ? $_POST['owner'] : null; |
|
| 146 | - $sharedBy = isset($_POST['sharedBy']) ? $_POST['sharedBy'] : null; |
|
| 147 | - $shareWith = isset($_POST['shareWith']) ? $_POST['shareWith'] : null; |
|
| 148 | - $remoteId = isset($_POST['remoteId']) ? (int)$_POST['remoteId'] : null; |
|
| 149 | - $sharedByFederatedId = isset($_POST['sharedByFederatedId']) ? $_POST['sharedByFederatedId'] : null; |
|
| 150 | - $ownerFederatedId = isset($_POST['ownerFederatedId']) ? $_POST['ownerFederatedId'] : null; |
|
| 151 | - |
|
| 152 | - if ($ownerFederatedId === null) { |
|
| 153 | - $ownerFederatedId = $this->cloudIdManager->getCloudId($owner, $this->cleanupRemote($remote))->getId(); |
|
| 154 | - } |
|
| 155 | - // if the owner of the share and the initiator are the same user |
|
| 156 | - // we also complete the federated share ID for the initiator |
|
| 157 | - if ($sharedByFederatedId === null && $owner === $sharedBy) { |
|
| 158 | - $sharedByFederatedId = $ownerFederatedId; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - $share = $this->cloudFederationFactory->getCloudFederationShare( |
|
| 162 | - $shareWith, |
|
| 163 | - $name, |
|
| 164 | - '', |
|
| 165 | - $remoteId, |
|
| 166 | - $ownerFederatedId, |
|
| 167 | - $owner, |
|
| 168 | - $sharedByFederatedId, |
|
| 169 | - $sharedBy, |
|
| 170 | - $token, |
|
| 171 | - 'user', |
|
| 172 | - 'file' |
|
| 173 | - ); |
|
| 174 | - |
|
| 175 | - try { |
|
| 176 | - $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file'); |
|
| 177 | - $provider->shareReceived($share); |
|
| 178 | - } catch (ProviderDoesNotExistsException $e) { |
|
| 179 | - throw new OCSException('Server does not support federated cloud sharing', 503); |
|
| 180 | - } catch (ProviderCouldNotAddShareException $e) { |
|
| 181 | - throw new OCSException($e->getMessage(), 400); |
|
| 182 | - } catch (\Exception $e) { |
|
| 183 | - throw new OCSException('internal server error, was not able to add share from ' . $remote, 500); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - return new Http\DataResponse(); |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * @NoCSRFRequired |
|
| 191 | - * @PublicPage |
|
| 192 | - * |
|
| 193 | - * create re-share on behalf of another user |
|
| 194 | - * |
|
| 195 | - * @param int $id |
|
| 196 | - * @return Http\DataResponse |
|
| 197 | - * @throws OCSBadRequestException |
|
| 198 | - * @throws OCSException |
|
| 199 | - * @throws OCSForbiddenException |
|
| 200 | - */ |
|
| 201 | - public function reShare($id) { |
|
| 202 | - |
|
| 203 | - $token = $this->request->getParam('token', null); |
|
| 204 | - $shareWith = $this->request->getParam('shareWith', null); |
|
| 205 | - $permission = (int)$this->request->getParam('permission', null); |
|
| 206 | - $remoteId = (int)$this->request->getParam('remoteId', null); |
|
| 207 | - |
|
| 208 | - if ($id === null || |
|
| 209 | - $token === null || |
|
| 210 | - $shareWith === null || |
|
| 211 | - $permission === null || |
|
| 212 | - $remoteId === null |
|
| 213 | - ) { |
|
| 214 | - throw new OCSBadRequestException(); |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - $notification = [ |
|
| 218 | - 'sharedSecret' => $token, |
|
| 219 | - 'shareWith' => $shareWith, |
|
| 220 | - 'senderId' => $remoteId, |
|
| 221 | - 'message' => 'Recipient of a share ask the owner to reshare the file' |
|
| 222 | - ]; |
|
| 223 | - |
|
| 224 | - try { |
|
| 225 | - $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file'); |
|
| 226 | - list($newToken, $localId) = $provider->notificationReceived('REQUEST_RESHARE', $id, $notification); |
|
| 227 | - return new Http\DataResponse([ |
|
| 228 | - 'token' => $newToken, |
|
| 229 | - 'remoteId' => $localId |
|
| 230 | - ]); |
|
| 231 | - } catch (ProviderDoesNotExistsException $e) { |
|
| 232 | - throw new OCSException('Server does not support federated cloud sharing', 503); |
|
| 233 | - } catch (ShareNotFound $e) { |
|
| 234 | - $this->logger->debug('Share not found: ' . $e->getMessage()); |
|
| 235 | - } catch (\Exception $e) { |
|
| 236 | - $this->logger->debug('internal server error, can not process notification: ' . $e->getMessage()); |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - throw new OCSBadRequestException(); |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * @NoCSRFRequired |
|
| 245 | - * @PublicPage |
|
| 246 | - * |
|
| 247 | - * accept server-to-server share |
|
| 248 | - * |
|
| 249 | - * @param int $id |
|
| 250 | - * @return Http\DataResponse |
|
| 251 | - * @throws OCSException |
|
| 252 | - * @throws ShareNotFound |
|
| 253 | - * @throws \OC\HintException |
|
| 254 | - */ |
|
| 255 | - public function acceptShare($id) { |
|
| 256 | - |
|
| 257 | - $token = isset($_POST['token']) ? $_POST['token'] : null; |
|
| 258 | - |
|
| 259 | - $notification = [ |
|
| 260 | - 'sharedSecret' => $token, |
|
| 261 | - 'message' => 'Recipient accept the share' |
|
| 262 | - ]; |
|
| 263 | - |
|
| 264 | - try { |
|
| 265 | - $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file'); |
|
| 266 | - $provider->notificationReceived('SHARE_ACCEPTED', $id, $notification); |
|
| 267 | - } catch (ProviderDoesNotExistsException $e) { |
|
| 268 | - throw new OCSException('Server does not support federated cloud sharing', 503); |
|
| 269 | - } catch (ShareNotFound $e) { |
|
| 270 | - $this->logger->debug('Share not found: ' . $e->getMessage()); |
|
| 271 | - } catch (\Exception $e) { |
|
| 272 | - $this->logger->debug('internal server error, can not process notification: ' . $e->getMessage()); |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - return new Http\DataResponse(); |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * @NoCSRFRequired |
|
| 280 | - * @PublicPage |
|
| 281 | - * |
|
| 282 | - * decline server-to-server share |
|
| 283 | - * |
|
| 284 | - * @param int $id |
|
| 285 | - * @return Http\DataResponse |
|
| 286 | - * @throws OCSException |
|
| 287 | - */ |
|
| 288 | - public function declineShare($id) { |
|
| 289 | - |
|
| 290 | - $token = isset($_POST['token']) ? $_POST['token'] : null; |
|
| 291 | - |
|
| 292 | - $notification = [ |
|
| 293 | - 'sharedSecret' => $token, |
|
| 294 | - 'message' => 'Recipient declined the share' |
|
| 295 | - ]; |
|
| 296 | - |
|
| 297 | - try { |
|
| 298 | - $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file'); |
|
| 299 | - $provider->notificationReceived('SHARE_DECLINED', $id, $notification); |
|
| 300 | - } catch (ProviderDoesNotExistsException $e) { |
|
| 301 | - throw new OCSException('Server does not support federated cloud sharing', 503); |
|
| 302 | - } catch (ShareNotFound $e) { |
|
| 303 | - $this->logger->debug('Share not found: ' . $e->getMessage()); |
|
| 304 | - } catch (\Exception $e) { |
|
| 305 | - $this->logger->debug('internal server error, can not process notification: ' . $e->getMessage()); |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - return new Http\DataResponse(); |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - /** |
|
| 312 | - * @NoCSRFRequired |
|
| 313 | - * @PublicPage |
|
| 314 | - * |
|
| 315 | - * remove server-to-server share if it was unshared by the owner |
|
| 316 | - * |
|
| 317 | - * @param int $id |
|
| 318 | - * @return Http\DataResponse |
|
| 319 | - * @throws OCSException |
|
| 320 | - */ |
|
| 321 | - public function unshare($id) { |
|
| 322 | - |
|
| 323 | - if (!$this->isS2SEnabled()) { |
|
| 324 | - throw new OCSException('Server does not support federated cloud sharing', 503); |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - $token = isset($_POST['token']) ? $_POST['token'] : null; |
|
| 328 | - |
|
| 329 | - try { |
|
| 330 | - $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file'); |
|
| 331 | - $notification = ['sharedSecret' => $token]; |
|
| 332 | - $provider->notificationReceived('SHARE_UNSHARED', $id, $notification); |
|
| 333 | - } catch (\Exception $e) { |
|
| 334 | - $this->logger->debug('processing unshare notification failed: ' . $e->getMessage()); |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - return new Http\DataResponse(); |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - private function cleanupRemote($remote) { |
|
| 341 | - $remote = substr($remote, strpos($remote, '://') + 3); |
|
| 342 | - |
|
| 343 | - return rtrim($remote, '/'); |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - |
|
| 347 | - /** |
|
| 348 | - * @NoCSRFRequired |
|
| 349 | - * @PublicPage |
|
| 350 | - * |
|
| 351 | - * federated share was revoked, either by the owner or the re-sharer |
|
| 352 | - * |
|
| 353 | - * @param int $id |
|
| 354 | - * @return Http\DataResponse |
|
| 355 | - * @throws OCSBadRequestException |
|
| 356 | - */ |
|
| 357 | - public function revoke($id) { |
|
| 358 | - |
|
| 359 | - $token = $this->request->getParam('token'); |
|
| 360 | - |
|
| 361 | - try { |
|
| 362 | - $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file'); |
|
| 363 | - $notification = ['sharedSecret' => $token]; |
|
| 364 | - $provider->notificationReceived('RESHARE_UNDO', $id, $notification); |
|
| 365 | - return new Http\DataResponse(); |
|
| 366 | - } catch (\Exception $e) { |
|
| 367 | - throw new OCSBadRequestException(); |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * check if server-to-server sharing is enabled |
|
| 374 | - * |
|
| 375 | - * @param bool $incoming |
|
| 376 | - * @return bool |
|
| 377 | - */ |
|
| 378 | - private function isS2SEnabled($incoming = false) { |
|
| 379 | - |
|
| 380 | - $result = \OCP\App::isEnabled('files_sharing'); |
|
| 381 | - |
|
| 382 | - if ($incoming) { |
|
| 383 | - $result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled(); |
|
| 384 | - } else { |
|
| 385 | - $result = $result && $this->federatedShareProvider->isOutgoingServer2serverShareEnabled(); |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - return $result; |
|
| 389 | - } |
|
| 390 | - |
|
| 391 | - /** |
|
| 392 | - * @NoCSRFRequired |
|
| 393 | - * @PublicPage |
|
| 394 | - * |
|
| 395 | - * update share information to keep federated re-shares in sync |
|
| 396 | - * |
|
| 397 | - * @param int $id |
|
| 398 | - * @return Http\DataResponse |
|
| 399 | - * @throws OCSBadRequestException |
|
| 400 | - */ |
|
| 401 | - public function updatePermissions($id) { |
|
| 402 | - $token = $this->request->getParam('token', null); |
|
| 403 | - $ncPermissions = $this->request->getParam('permissions', null); |
|
| 404 | - |
|
| 405 | - try { |
|
| 406 | - $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file'); |
|
| 407 | - $ocmPermissions = $this->ncPermissions2ocmPermissions((int)$ncPermissions); |
|
| 408 | - $notification = ['sharedSecret' => $token, 'permission' => $ocmPermissions]; |
|
| 409 | - $provider->notificationReceived('RESHARE_CHANGE_PERMISSION', $id, $notification); |
|
| 410 | - } catch (\Exception $e) { |
|
| 411 | - $this->logger->debug($e->getMessage()); |
|
| 412 | - throw new OCSBadRequestException(); |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - return new Http\DataResponse(); |
|
| 416 | - } |
|
| 417 | - |
|
| 418 | - /** |
|
| 419 | - * translate Nextcloud permissions to OCM Permissions |
|
| 420 | - * |
|
| 421 | - * @param $ncPermissions |
|
| 422 | - * @return array |
|
| 423 | - */ |
|
| 424 | - protected function ncPermissions2ocmPermissions($ncPermissions) { |
|
| 425 | - |
|
| 426 | - $ocmPermissions = []; |
|
| 427 | - |
|
| 428 | - if ($ncPermissions & Constants::PERMISSION_SHARE) { |
|
| 429 | - $ocmPermissions[] = 'share'; |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - if ($ncPermissions & Constants::PERMISSION_READ) { |
|
| 433 | - $ocmPermissions[] = 'read'; |
|
| 434 | - } |
|
| 435 | - |
|
| 436 | - if (($ncPermissions & Constants::PERMISSION_CREATE) || |
|
| 437 | - ($ncPermissions & Constants::PERMISSION_UPDATE)) { |
|
| 438 | - $ocmPermissions[] = 'write'; |
|
| 439 | - } |
|
| 440 | - |
|
| 441 | - return $ocmPermissions; |
|
| 442 | - |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - /** |
|
| 446 | - * @NoCSRFRequired |
|
| 447 | - * @PublicPage |
|
| 448 | - * |
|
| 449 | - * change the owner of a server-to-server share |
|
| 450 | - * |
|
| 451 | - * @param int $id |
|
| 452 | - * @return Http\DataResponse |
|
| 453 | - * @throws \InvalidArgumentException |
|
| 454 | - * @throws OCSException |
|
| 455 | - */ |
|
| 456 | - public function move($id) { |
|
| 457 | - |
|
| 458 | - if (!$this->isS2SEnabled()) { |
|
| 459 | - throw new OCSException('Server does not support federated cloud sharing', 503); |
|
| 460 | - } |
|
| 461 | - |
|
| 462 | - $token = $this->request->getParam('token'); |
|
| 463 | - $remote = $this->request->getParam('remote'); |
|
| 464 | - $newRemoteId = $this->request->getParam('remote_id', $id); |
|
| 465 | - $cloudId = $this->cloudIdManager->resolveCloudId($remote); |
|
| 466 | - |
|
| 467 | - $qb = $this->connection->getQueryBuilder(); |
|
| 468 | - $query = $qb->update('share_external') |
|
| 469 | - ->set('remote', $qb->createNamedParameter($cloudId->getRemote())) |
|
| 470 | - ->set('owner', $qb->createNamedParameter($cloudId->getUser())) |
|
| 471 | - ->set('remote_id', $qb->createNamedParameter($newRemoteId)) |
|
| 472 | - ->where($qb->expr()->eq('remote_id', $qb->createNamedParameter($id))) |
|
| 473 | - ->andWhere($qb->expr()->eq('share_token', $qb->createNamedParameter($token))); |
|
| 474 | - $affected = $query->execute(); |
|
| 475 | - |
|
| 476 | - if ($affected > 0) { |
|
| 477 | - return new Http\DataResponse(['remote' => $cloudId->getRemote(), 'owner' => $cloudId->getUser()]); |
|
| 478 | - } else { |
|
| 479 | - throw new OCSBadRequestException('Share not found or token invalid'); |
|
| 480 | - } |
|
| 481 | - } |
|
| 55 | + /** @var FederatedShareProvider */ |
|
| 56 | + private $federatedShareProvider; |
|
| 57 | + |
|
| 58 | + /** @var IDBConnection */ |
|
| 59 | + private $connection; |
|
| 60 | + |
|
| 61 | + /** @var Share\IManager */ |
|
| 62 | + private $shareManager; |
|
| 63 | + |
|
| 64 | + /** @var Notifications */ |
|
| 65 | + private $notifications; |
|
| 66 | + |
|
| 67 | + /** @var AddressHandler */ |
|
| 68 | + private $addressHandler; |
|
| 69 | + |
|
| 70 | + /** @var IUserManager */ |
|
| 71 | + private $userManager; |
|
| 72 | + |
|
| 73 | + /** @var string */ |
|
| 74 | + private $shareTable = 'share'; |
|
| 75 | + |
|
| 76 | + /** @var ICloudIdManager */ |
|
| 77 | + private $cloudIdManager; |
|
| 78 | + |
|
| 79 | + /** @var ILogger */ |
|
| 80 | + private $logger; |
|
| 81 | + |
|
| 82 | + /** @var ICloudFederationFactory */ |
|
| 83 | + private $cloudFederationFactory; |
|
| 84 | + |
|
| 85 | + /** @var ICloudFederationProviderManager */ |
|
| 86 | + private $cloudFederationProviderManager; |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Server2Server constructor. |
|
| 90 | + * |
|
| 91 | + * @param string $appName |
|
| 92 | + * @param IRequest $request |
|
| 93 | + * @param FederatedShareProvider $federatedShareProvider |
|
| 94 | + * @param IDBConnection $connection |
|
| 95 | + * @param Share\IManager $shareManager |
|
| 96 | + * @param Notifications $notifications |
|
| 97 | + * @param AddressHandler $addressHandler |
|
| 98 | + * @param IUserManager $userManager |
|
| 99 | + * @param ICloudIdManager $cloudIdManager |
|
| 100 | + * @param ILogger $logger |
|
| 101 | + * @param ICloudFederationFactory $cloudFederationFactory |
|
| 102 | + * @param ICloudFederationProviderManager $cloudFederationProviderManager |
|
| 103 | + */ |
|
| 104 | + public function __construct($appName, |
|
| 105 | + IRequest $request, |
|
| 106 | + FederatedShareProvider $federatedShareProvider, |
|
| 107 | + IDBConnection $connection, |
|
| 108 | + Share\IManager $shareManager, |
|
| 109 | + Notifications $notifications, |
|
| 110 | + AddressHandler $addressHandler, |
|
| 111 | + IUserManager $userManager, |
|
| 112 | + ICloudIdManager $cloudIdManager, |
|
| 113 | + ILogger $logger, |
|
| 114 | + ICloudFederationFactory $cloudFederationFactory, |
|
| 115 | + ICloudFederationProviderManager $cloudFederationProviderManager |
|
| 116 | + ) { |
|
| 117 | + parent::__construct($appName, $request); |
|
| 118 | + |
|
| 119 | + $this->federatedShareProvider = $federatedShareProvider; |
|
| 120 | + $this->connection = $connection; |
|
| 121 | + $this->shareManager = $shareManager; |
|
| 122 | + $this->notifications = $notifications; |
|
| 123 | + $this->addressHandler = $addressHandler; |
|
| 124 | + $this->userManager = $userManager; |
|
| 125 | + $this->cloudIdManager = $cloudIdManager; |
|
| 126 | + $this->logger = $logger; |
|
| 127 | + $this->cloudFederationFactory = $cloudFederationFactory; |
|
| 128 | + $this->cloudFederationProviderManager = $cloudFederationProviderManager; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @NoCSRFRequired |
|
| 133 | + * @PublicPage |
|
| 134 | + * |
|
| 135 | + * create a new share |
|
| 136 | + * |
|
| 137 | + * @return Http\DataResponse |
|
| 138 | + * @throws OCSException |
|
| 139 | + */ |
|
| 140 | + public function createShare() { |
|
| 141 | + |
|
| 142 | + $remote = isset($_POST['remote']) ? $_POST['remote'] : null; |
|
| 143 | + $token = isset($_POST['token']) ? $_POST['token'] : null; |
|
| 144 | + $name = isset($_POST['name']) ? $_POST['name'] : null; |
|
| 145 | + $owner = isset($_POST['owner']) ? $_POST['owner'] : null; |
|
| 146 | + $sharedBy = isset($_POST['sharedBy']) ? $_POST['sharedBy'] : null; |
|
| 147 | + $shareWith = isset($_POST['shareWith']) ? $_POST['shareWith'] : null; |
|
| 148 | + $remoteId = isset($_POST['remoteId']) ? (int)$_POST['remoteId'] : null; |
|
| 149 | + $sharedByFederatedId = isset($_POST['sharedByFederatedId']) ? $_POST['sharedByFederatedId'] : null; |
|
| 150 | + $ownerFederatedId = isset($_POST['ownerFederatedId']) ? $_POST['ownerFederatedId'] : null; |
|
| 151 | + |
|
| 152 | + if ($ownerFederatedId === null) { |
|
| 153 | + $ownerFederatedId = $this->cloudIdManager->getCloudId($owner, $this->cleanupRemote($remote))->getId(); |
|
| 154 | + } |
|
| 155 | + // if the owner of the share and the initiator are the same user |
|
| 156 | + // we also complete the federated share ID for the initiator |
|
| 157 | + if ($sharedByFederatedId === null && $owner === $sharedBy) { |
|
| 158 | + $sharedByFederatedId = $ownerFederatedId; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + $share = $this->cloudFederationFactory->getCloudFederationShare( |
|
| 162 | + $shareWith, |
|
| 163 | + $name, |
|
| 164 | + '', |
|
| 165 | + $remoteId, |
|
| 166 | + $ownerFederatedId, |
|
| 167 | + $owner, |
|
| 168 | + $sharedByFederatedId, |
|
| 169 | + $sharedBy, |
|
| 170 | + $token, |
|
| 171 | + 'user', |
|
| 172 | + 'file' |
|
| 173 | + ); |
|
| 174 | + |
|
| 175 | + try { |
|
| 176 | + $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file'); |
|
| 177 | + $provider->shareReceived($share); |
|
| 178 | + } catch (ProviderDoesNotExistsException $e) { |
|
| 179 | + throw new OCSException('Server does not support federated cloud sharing', 503); |
|
| 180 | + } catch (ProviderCouldNotAddShareException $e) { |
|
| 181 | + throw new OCSException($e->getMessage(), 400); |
|
| 182 | + } catch (\Exception $e) { |
|
| 183 | + throw new OCSException('internal server error, was not able to add share from ' . $remote, 500); |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + return new Http\DataResponse(); |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * @NoCSRFRequired |
|
| 191 | + * @PublicPage |
|
| 192 | + * |
|
| 193 | + * create re-share on behalf of another user |
|
| 194 | + * |
|
| 195 | + * @param int $id |
|
| 196 | + * @return Http\DataResponse |
|
| 197 | + * @throws OCSBadRequestException |
|
| 198 | + * @throws OCSException |
|
| 199 | + * @throws OCSForbiddenException |
|
| 200 | + */ |
|
| 201 | + public function reShare($id) { |
|
| 202 | + |
|
| 203 | + $token = $this->request->getParam('token', null); |
|
| 204 | + $shareWith = $this->request->getParam('shareWith', null); |
|
| 205 | + $permission = (int)$this->request->getParam('permission', null); |
|
| 206 | + $remoteId = (int)$this->request->getParam('remoteId', null); |
|
| 207 | + |
|
| 208 | + if ($id === null || |
|
| 209 | + $token === null || |
|
| 210 | + $shareWith === null || |
|
| 211 | + $permission === null || |
|
| 212 | + $remoteId === null |
|
| 213 | + ) { |
|
| 214 | + throw new OCSBadRequestException(); |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + $notification = [ |
|
| 218 | + 'sharedSecret' => $token, |
|
| 219 | + 'shareWith' => $shareWith, |
|
| 220 | + 'senderId' => $remoteId, |
|
| 221 | + 'message' => 'Recipient of a share ask the owner to reshare the file' |
|
| 222 | + ]; |
|
| 223 | + |
|
| 224 | + try { |
|
| 225 | + $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file'); |
|
| 226 | + list($newToken, $localId) = $provider->notificationReceived('REQUEST_RESHARE', $id, $notification); |
|
| 227 | + return new Http\DataResponse([ |
|
| 228 | + 'token' => $newToken, |
|
| 229 | + 'remoteId' => $localId |
|
| 230 | + ]); |
|
| 231 | + } catch (ProviderDoesNotExistsException $e) { |
|
| 232 | + throw new OCSException('Server does not support federated cloud sharing', 503); |
|
| 233 | + } catch (ShareNotFound $e) { |
|
| 234 | + $this->logger->debug('Share not found: ' . $e->getMessage()); |
|
| 235 | + } catch (\Exception $e) { |
|
| 236 | + $this->logger->debug('internal server error, can not process notification: ' . $e->getMessage()); |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + throw new OCSBadRequestException(); |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * @NoCSRFRequired |
|
| 245 | + * @PublicPage |
|
| 246 | + * |
|
| 247 | + * accept server-to-server share |
|
| 248 | + * |
|
| 249 | + * @param int $id |
|
| 250 | + * @return Http\DataResponse |
|
| 251 | + * @throws OCSException |
|
| 252 | + * @throws ShareNotFound |
|
| 253 | + * @throws \OC\HintException |
|
| 254 | + */ |
|
| 255 | + public function acceptShare($id) { |
|
| 256 | + |
|
| 257 | + $token = isset($_POST['token']) ? $_POST['token'] : null; |
|
| 258 | + |
|
| 259 | + $notification = [ |
|
| 260 | + 'sharedSecret' => $token, |
|
| 261 | + 'message' => 'Recipient accept the share' |
|
| 262 | + ]; |
|
| 263 | + |
|
| 264 | + try { |
|
| 265 | + $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file'); |
|
| 266 | + $provider->notificationReceived('SHARE_ACCEPTED', $id, $notification); |
|
| 267 | + } catch (ProviderDoesNotExistsException $e) { |
|
| 268 | + throw new OCSException('Server does not support federated cloud sharing', 503); |
|
| 269 | + } catch (ShareNotFound $e) { |
|
| 270 | + $this->logger->debug('Share not found: ' . $e->getMessage()); |
|
| 271 | + } catch (\Exception $e) { |
|
| 272 | + $this->logger->debug('internal server error, can not process notification: ' . $e->getMessage()); |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + return new Http\DataResponse(); |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * @NoCSRFRequired |
|
| 280 | + * @PublicPage |
|
| 281 | + * |
|
| 282 | + * decline server-to-server share |
|
| 283 | + * |
|
| 284 | + * @param int $id |
|
| 285 | + * @return Http\DataResponse |
|
| 286 | + * @throws OCSException |
|
| 287 | + */ |
|
| 288 | + public function declineShare($id) { |
|
| 289 | + |
|
| 290 | + $token = isset($_POST['token']) ? $_POST['token'] : null; |
|
| 291 | + |
|
| 292 | + $notification = [ |
|
| 293 | + 'sharedSecret' => $token, |
|
| 294 | + 'message' => 'Recipient declined the share' |
|
| 295 | + ]; |
|
| 296 | + |
|
| 297 | + try { |
|
| 298 | + $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file'); |
|
| 299 | + $provider->notificationReceived('SHARE_DECLINED', $id, $notification); |
|
| 300 | + } catch (ProviderDoesNotExistsException $e) { |
|
| 301 | + throw new OCSException('Server does not support federated cloud sharing', 503); |
|
| 302 | + } catch (ShareNotFound $e) { |
|
| 303 | + $this->logger->debug('Share not found: ' . $e->getMessage()); |
|
| 304 | + } catch (\Exception $e) { |
|
| 305 | + $this->logger->debug('internal server error, can not process notification: ' . $e->getMessage()); |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + return new Http\DataResponse(); |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + /** |
|
| 312 | + * @NoCSRFRequired |
|
| 313 | + * @PublicPage |
|
| 314 | + * |
|
| 315 | + * remove server-to-server share if it was unshared by the owner |
|
| 316 | + * |
|
| 317 | + * @param int $id |
|
| 318 | + * @return Http\DataResponse |
|
| 319 | + * @throws OCSException |
|
| 320 | + */ |
|
| 321 | + public function unshare($id) { |
|
| 322 | + |
|
| 323 | + if (!$this->isS2SEnabled()) { |
|
| 324 | + throw new OCSException('Server does not support federated cloud sharing', 503); |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + $token = isset($_POST['token']) ? $_POST['token'] : null; |
|
| 328 | + |
|
| 329 | + try { |
|
| 330 | + $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file'); |
|
| 331 | + $notification = ['sharedSecret' => $token]; |
|
| 332 | + $provider->notificationReceived('SHARE_UNSHARED', $id, $notification); |
|
| 333 | + } catch (\Exception $e) { |
|
| 334 | + $this->logger->debug('processing unshare notification failed: ' . $e->getMessage()); |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + return new Http\DataResponse(); |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + private function cleanupRemote($remote) { |
|
| 341 | + $remote = substr($remote, strpos($remote, '://') + 3); |
|
| 342 | + |
|
| 343 | + return rtrim($remote, '/'); |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + |
|
| 347 | + /** |
|
| 348 | + * @NoCSRFRequired |
|
| 349 | + * @PublicPage |
|
| 350 | + * |
|
| 351 | + * federated share was revoked, either by the owner or the re-sharer |
|
| 352 | + * |
|
| 353 | + * @param int $id |
|
| 354 | + * @return Http\DataResponse |
|
| 355 | + * @throws OCSBadRequestException |
|
| 356 | + */ |
|
| 357 | + public function revoke($id) { |
|
| 358 | + |
|
| 359 | + $token = $this->request->getParam('token'); |
|
| 360 | + |
|
| 361 | + try { |
|
| 362 | + $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file'); |
|
| 363 | + $notification = ['sharedSecret' => $token]; |
|
| 364 | + $provider->notificationReceived('RESHARE_UNDO', $id, $notification); |
|
| 365 | + return new Http\DataResponse(); |
|
| 366 | + } catch (\Exception $e) { |
|
| 367 | + throw new OCSBadRequestException(); |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + /** |
|
| 373 | + * check if server-to-server sharing is enabled |
|
| 374 | + * |
|
| 375 | + * @param bool $incoming |
|
| 376 | + * @return bool |
|
| 377 | + */ |
|
| 378 | + private function isS2SEnabled($incoming = false) { |
|
| 379 | + |
|
| 380 | + $result = \OCP\App::isEnabled('files_sharing'); |
|
| 381 | + |
|
| 382 | + if ($incoming) { |
|
| 383 | + $result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled(); |
|
| 384 | + } else { |
|
| 385 | + $result = $result && $this->federatedShareProvider->isOutgoingServer2serverShareEnabled(); |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + return $result; |
|
| 389 | + } |
|
| 390 | + |
|
| 391 | + /** |
|
| 392 | + * @NoCSRFRequired |
|
| 393 | + * @PublicPage |
|
| 394 | + * |
|
| 395 | + * update share information to keep federated re-shares in sync |
|
| 396 | + * |
|
| 397 | + * @param int $id |
|
| 398 | + * @return Http\DataResponse |
|
| 399 | + * @throws OCSBadRequestException |
|
| 400 | + */ |
|
| 401 | + public function updatePermissions($id) { |
|
| 402 | + $token = $this->request->getParam('token', null); |
|
| 403 | + $ncPermissions = $this->request->getParam('permissions', null); |
|
| 404 | + |
|
| 405 | + try { |
|
| 406 | + $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file'); |
|
| 407 | + $ocmPermissions = $this->ncPermissions2ocmPermissions((int)$ncPermissions); |
|
| 408 | + $notification = ['sharedSecret' => $token, 'permission' => $ocmPermissions]; |
|
| 409 | + $provider->notificationReceived('RESHARE_CHANGE_PERMISSION', $id, $notification); |
|
| 410 | + } catch (\Exception $e) { |
|
| 411 | + $this->logger->debug($e->getMessage()); |
|
| 412 | + throw new OCSBadRequestException(); |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + return new Http\DataResponse(); |
|
| 416 | + } |
|
| 417 | + |
|
| 418 | + /** |
|
| 419 | + * translate Nextcloud permissions to OCM Permissions |
|
| 420 | + * |
|
| 421 | + * @param $ncPermissions |
|
| 422 | + * @return array |
|
| 423 | + */ |
|
| 424 | + protected function ncPermissions2ocmPermissions($ncPermissions) { |
|
| 425 | + |
|
| 426 | + $ocmPermissions = []; |
|
| 427 | + |
|
| 428 | + if ($ncPermissions & Constants::PERMISSION_SHARE) { |
|
| 429 | + $ocmPermissions[] = 'share'; |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + if ($ncPermissions & Constants::PERMISSION_READ) { |
|
| 433 | + $ocmPermissions[] = 'read'; |
|
| 434 | + } |
|
| 435 | + |
|
| 436 | + if (($ncPermissions & Constants::PERMISSION_CREATE) || |
|
| 437 | + ($ncPermissions & Constants::PERMISSION_UPDATE)) { |
|
| 438 | + $ocmPermissions[] = 'write'; |
|
| 439 | + } |
|
| 440 | + |
|
| 441 | + return $ocmPermissions; |
|
| 442 | + |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + /** |
|
| 446 | + * @NoCSRFRequired |
|
| 447 | + * @PublicPage |
|
| 448 | + * |
|
| 449 | + * change the owner of a server-to-server share |
|
| 450 | + * |
|
| 451 | + * @param int $id |
|
| 452 | + * @return Http\DataResponse |
|
| 453 | + * @throws \InvalidArgumentException |
|
| 454 | + * @throws OCSException |
|
| 455 | + */ |
|
| 456 | + public function move($id) { |
|
| 457 | + |
|
| 458 | + if (!$this->isS2SEnabled()) { |
|
| 459 | + throw new OCSException('Server does not support federated cloud sharing', 503); |
|
| 460 | + } |
|
| 461 | + |
|
| 462 | + $token = $this->request->getParam('token'); |
|
| 463 | + $remote = $this->request->getParam('remote'); |
|
| 464 | + $newRemoteId = $this->request->getParam('remote_id', $id); |
|
| 465 | + $cloudId = $this->cloudIdManager->resolveCloudId($remote); |
|
| 466 | + |
|
| 467 | + $qb = $this->connection->getQueryBuilder(); |
|
| 468 | + $query = $qb->update('share_external') |
|
| 469 | + ->set('remote', $qb->createNamedParameter($cloudId->getRemote())) |
|
| 470 | + ->set('owner', $qb->createNamedParameter($cloudId->getUser())) |
|
| 471 | + ->set('remote_id', $qb->createNamedParameter($newRemoteId)) |
|
| 472 | + ->where($qb->expr()->eq('remote_id', $qb->createNamedParameter($id))) |
|
| 473 | + ->andWhere($qb->expr()->eq('share_token', $qb->createNamedParameter($token))); |
|
| 474 | + $affected = $query->execute(); |
|
| 475 | + |
|
| 476 | + if ($affected > 0) { |
|
| 477 | + return new Http\DataResponse(['remote' => $cloudId->getRemote(), 'owner' => $cloudId->getUser()]); |
|
| 478 | + } else { |
|
| 479 | + throw new OCSBadRequestException('Share not found or token invalid'); |
|
| 480 | + } |
|
| 481 | + } |
|
| 482 | 482 | } |
@@ -32,36 +32,36 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class CloudFederationNotification implements ICloudFederationNotification { |
| 34 | 34 | |
| 35 | - private $message = []; |
|
| 35 | + private $message = []; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * add a message to the notification |
|
| 39 | - * |
|
| 40 | - * @param string $notificationType (e.g. SHARE_ACCEPTED) |
|
| 41 | - * @param string $resourceType (e.g. file, calendar, contact,...) |
|
| 42 | - * @param string $providerId id of the share |
|
| 43 | - * @param array $notification payload of the notification |
|
| 44 | - * |
|
| 45 | - * @since 14.0.0 |
|
| 46 | - */ |
|
| 47 | - public function setMessage($notificationType, $resourceType, $providerId, array $notification) { |
|
| 48 | - $this->message = [ |
|
| 49 | - 'notificationType' => $notificationType, |
|
| 50 | - 'resourceType' => $resourceType, |
|
| 51 | - 'providerId' => $providerId, |
|
| 52 | - 'notification' => $notification, |
|
| 53 | - ]; |
|
| 37 | + /** |
|
| 38 | + * add a message to the notification |
|
| 39 | + * |
|
| 40 | + * @param string $notificationType (e.g. SHARE_ACCEPTED) |
|
| 41 | + * @param string $resourceType (e.g. file, calendar, contact,...) |
|
| 42 | + * @param string $providerId id of the share |
|
| 43 | + * @param array $notification payload of the notification |
|
| 44 | + * |
|
| 45 | + * @since 14.0.0 |
|
| 46 | + */ |
|
| 47 | + public function setMessage($notificationType, $resourceType, $providerId, array $notification) { |
|
| 48 | + $this->message = [ |
|
| 49 | + 'notificationType' => $notificationType, |
|
| 50 | + 'resourceType' => $resourceType, |
|
| 51 | + 'providerId' => $providerId, |
|
| 52 | + 'notification' => $notification, |
|
| 53 | + ]; |
|
| 54 | 54 | |
| 55 | - } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * get message, ready to send out |
|
| 59 | - * |
|
| 60 | - * @return array |
|
| 61 | - * |
|
| 62 | - * @since 14.0.0 |
|
| 63 | - */ |
|
| 64 | - public function getMessage() { |
|
| 65 | - return $this->message; |
|
| 66 | - } |
|
| 57 | + /** |
|
| 58 | + * get message, ready to send out |
|
| 59 | + * |
|
| 60 | + * @return array |
|
| 61 | + * |
|
| 62 | + * @since 14.0.0 |
|
| 63 | + */ |
|
| 64 | + public function getMessage() { |
|
| 65 | + return $this->message; |
|
| 66 | + } |
|
| 67 | 67 | } |