3333use OCP \AppFramework \Http ;
3434use OCP \AppFramework \OCS \OCSBadRequestException ;
3535use OCP \AppFramework \OCS \OCSException ;
36- use OCP \AppFramework \OCS \OCSForbiddenException ;
3736use OCP \AppFramework \OCSController ;
3837use OCP \App \IAppManager ;
3938use OCP \Constants ;
@@ -124,20 +123,29 @@ public function __construct(string $appName,
124123 *
125124 * create a new share
126125 *
126+ * @param string|null $remote
127+ * @param string|null $token
128+ * @param string|null $name
129+ * @param string|null $owner
130+ * @param string|null $sharedBy
131+ * @param string|null $shareWith
132+ * @param int|null $remoteId
133+ * @param string|null $sharedByFederatedId
134+ * @param string|null $ownerFederatedId
127135 * @return Http\DataResponse
128136 * @throws OCSException
129137 */
130- public function createShare () {
131- $ remote = isset ( $ _POST [ ' remote ' ]) ? $ _POST [ ' remote ' ] : null ;
132- $ token = isset ( $ _POST [ ' token ' ]) ? $ _POST [ ' token ' ] : null ;
133- $ name = isset ( $ _POST [ ' name ' ]) ? $ _POST [ ' name ' ] : null ;
134- $ owner = isset ( $ _POST [ ' owner ' ]) ? $ _POST [ ' owner ' ] : null ;
135- $ sharedBy = isset ( $ _POST [ ' sharedBy ' ]) ? $ _POST [ ' sharedBy ' ] : null ;
136- $ shareWith = isset ( $ _POST [ ' shareWith ' ]) ? $ _POST [ ' shareWith ' ] : null ;
137- $ remoteId = isset ( $ _POST [ ' remoteId ' ]) ? ( int ) $ _POST [ ' remoteId ' ] : null ;
138- $ sharedByFederatedId = isset ( $ _POST [ ' sharedByFederatedId ' ]) ? $ _POST [ ' sharedByFederatedId ' ] : null ;
139- $ ownerFederatedId = isset ( $ _POST [ ' ownerFederatedId ' ]) ? $ _POST [ ' ownerFederatedId ' ] : null ;
140-
138+ public function createShare (
139+ ? string $ remote = null ,
140+ ? string $ token = null ,
141+ ? string $ name = null ,
142+ ? string $ owner = null ,
143+ ? string $ sharedBy = null ,
144+ ? string $ shareWith = null ,
145+ ? int $ remoteId = null ,
146+ ? string $ sharedByFederatedId = null ,
147+ ? string $ ownerFederatedId = null ,
148+ ) {
141149 if ($ ownerFederatedId === null ) {
142150 $ ownerFederatedId = $ this ->cloudIdManager ->getCloudId ($ owner , $ this ->cleanupRemote ($ remote ))->getId ();
143151 }
@@ -187,19 +195,16 @@ public function createShare() {
187195 * create re-share on behalf of another user
188196 *
189197 * @param int $id
198+ * @param string|null $token
199+ * @param string|null $shareWith
200+ * @param int|null $permission
201+ * @param int|null $remoteId
190202 * @return Http\DataResponse
191203 * @throws OCSBadRequestException
192204 * @throws OCSException
193- * @throws OCSForbiddenException
194205 */
195- public function reShare ($ id ) {
196- $ token = $ this ->request ->getParam ('token ' , null );
197- $ shareWith = $ this ->request ->getParam ('shareWith ' , null );
198- $ permission = (int )$ this ->request ->getParam ('permission ' , null );
199- $ remoteId = (int )$ this ->request ->getParam ('remoteId ' , null );
200-
201- if ($ id === null ||
202- $ token === null ||
206+ public function reShare (int $ id , ?string $ token = null , ?string $ shareWith = null , ?int $ permission = 0 , ?int $ remoteId = 0 ) {
207+ if ($ token === null ||
203208 $ shareWith === null ||
204209 $ permission === null ||
205210 $ remoteId === null
@@ -240,14 +245,13 @@ public function reShare($id) {
240245 * accept server-to-server share
241246 *
242247 * @param int $id
248+ * @param string|null $token
243249 * @return Http\DataResponse
244250 * @throws OCSException
245251 * @throws ShareNotFound
246252 * @throws \OCP\HintException
247253 */
248- public function acceptShare ($ id ) {
249- $ token = isset ($ _POST ['token ' ]) ? $ _POST ['token ' ] : null ;
250-
254+ public function acceptShare (int $ id , ?string $ token = null ) {
251255 $ notification = [
252256 'sharedSecret ' => $ token ,
253257 'message ' => 'Recipient accept the share '
@@ -275,12 +279,11 @@ public function acceptShare($id) {
275279 * decline server-to-server share
276280 *
277281 * @param int $id
282+ * @param string|null $token
278283 * @return Http\DataResponse
279284 * @throws OCSException
280285 */
281- public function declineShare ($ id ) {
282- $ token = isset ($ _POST ['token ' ]) ? $ _POST ['token ' ] : null ;
283-
286+ public function declineShare (int $ id , ?string $ token = null ) {
284287 $ notification = [
285288 'sharedSecret ' => $ token ,
286289 'message ' => 'Recipient declined the share '
@@ -308,16 +311,15 @@ public function declineShare($id) {
308311 * remove server-to-server share if it was unshared by the owner
309312 *
310313 * @param int $id
314+ * @param string|null $token
311315 * @return Http\DataResponse
312316 * @throws OCSException
313317 */
314- public function unshare ($ id ) {
318+ public function unshare (int $ id, ? string $ token = null ) {
315319 if (!$ this ->isS2SEnabled ()) {
316320 throw new OCSException ('Server does not support federated cloud sharing ' , 503 );
317321 }
318322
319- $ token = isset ($ _POST ['token ' ]) ? $ _POST ['token ' ] : null ;
320-
321323 try {
322324 $ provider = $ this ->cloudFederationProviderManager ->getCloudFederationProvider ('file ' );
323325 $ notification = ['sharedSecret ' => $ token ];
@@ -344,12 +346,11 @@ private function cleanupRemote($remote) {
344346 * federated share was revoked, either by the owner or the re-sharer
345347 *
346348 * @param int $id
349+ * @param string|null $token
347350 * @return Http\DataResponse
348351 * @throws OCSBadRequestException
349352 */
350- public function revoke ($ id ) {
351- $ token = $ this ->request ->getParam ('token ' );
352-
353+ public function revoke (int $ id , ?string $ token = null ) {
353354 try {
354355 $ provider = $ this ->cloudFederationProviderManager ->getCloudFederationProvider ('file ' );
355356 $ notification = ['sharedSecret ' => $ token ];
@@ -385,12 +386,13 @@ private function isS2SEnabled($incoming = false) {
385386 * update share information to keep federated re-shares in sync
386387 *
387388 * @param int $id
389+ * @param string|null $token
390+ * @param int|null $permissions
388391 * @return Http\DataResponse
389392 * @throws OCSBadRequestException
390393 */
391- public function updatePermissions ($ id ) {
392- $ token = $ this ->request ->getParam ('token ' , null );
393- $ ncPermissions = $ this ->request ->getParam ('permissions ' , null );
394+ public function updatePermissions (int $ id , ?string $ token = null , ?int $ permissions = null ) {
395+ $ ncPermissions = $ permissions ;
394396
395397 try {
396398 $ provider = $ this ->cloudFederationProviderManager ->getCloudFederationProvider ('file ' );
@@ -438,18 +440,20 @@ protected function ncPermissions2ocmPermissions($ncPermissions) {
438440 * change the owner of a server-to-server share
439441 *
440442 * @param int $id
443+ * @param string|null $token
444+ * @param string|null $remote
445+ * @param string|null $remote_id
441446 * @return Http\DataResponse
442- * @throws \InvalidArgumentException
447+ * @throws OCSBadRequestException
443448 * @throws OCSException
449+ * @throws \OCP\DB\Exception
444450 */
445- public function move ($ id ) {
451+ public function move (int $ id, ? string $ token = null , ? string $ remote = null , ? string $ remote_id = null ) {
446452 if (!$ this ->isS2SEnabled ()) {
447453 throw new OCSException ('Server does not support federated cloud sharing ' , 503 );
448454 }
449455
450- $ token = $ this ->request ->getParam ('token ' );
451- $ remote = $ this ->request ->getParam ('remote ' );
452- $ newRemoteId = $ this ->request ->getParam ('remote_id ' , $ id );
456+ $ newRemoteId = (string ) ($ remote_id ?? $ id );
453457 $ cloudId = $ this ->cloudIdManager ->resolveCloudId ($ remote );
454458
455459 $ qb = $ this ->connection ->getQueryBuilder ();
0 commit comments