summaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/federatedfilesharing/lib')
-rw-r--r--apps/federatedfilesharing/lib/AddressHandler.php1
-rw-r--r--apps/federatedfilesharing/lib/AppInfo/Application.php2
-rw-r--r--apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php3
-rw-r--r--apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php1
-rw-r--r--apps/federatedfilesharing/lib/Controller/RequestHandlerController.php11
-rw-r--r--apps/federatedfilesharing/lib/FederatedShareProvider.php21
-rw-r--r--apps/federatedfilesharing/lib/Notifications.php8
-rw-r--r--apps/federatedfilesharing/lib/Settings/Admin.php2
-rw-r--r--apps/federatedfilesharing/lib/TokenHandler.php2
-rw-r--r--apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php19
10 files changed, 8 insertions, 62 deletions
diff --git a/apps/federatedfilesharing/lib/AddressHandler.php b/apps/federatedfilesharing/lib/AddressHandler.php
index 7ea3f304664..3a48e2adc86 100644
--- a/apps/federatedfilesharing/lib/AddressHandler.php
+++ b/apps/federatedfilesharing/lib/AddressHandler.php
@@ -149,7 +149,6 @@ class AddressHandler {
public function urlContainProtocol($url) {
if (strpos($url, 'https://') === 0 ||
strpos($url, 'http://') === 0) {
-
return true;
}
diff --git a/apps/federatedfilesharing/lib/AppInfo/Application.php b/apps/federatedfilesharing/lib/AppInfo/Application.php
index 34666a62027..6dcb937605d 100644
--- a/apps/federatedfilesharing/lib/AppInfo/Application.php
+++ b/apps/federatedfilesharing/lib/AppInfo/Application.php
@@ -117,7 +117,6 @@ class Application extends App {
}
}
);
-
}
/**
@@ -170,5 +169,4 @@ class Application extends App {
);
}
-
}
diff --git a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
index ebbff7b9c34..8af2d587fae 100644
--- a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
+++ b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
@@ -79,7 +79,6 @@ class RetryJob extends Job {
\OC::$server->getCloudFederationFactory()
);
}
-
}
/**
@@ -89,7 +88,6 @@ class RetryJob extends Job {
* @param ILogger|null $logger
*/
public function execute($jobList, ILogger $logger = null) {
-
if ($this->shouldRun($this->argument)) {
parent::execute($jobList, $logger);
$jobList->remove($this, $this->argument);
@@ -144,5 +142,4 @@ class RetryJob extends Job {
$lastRun = (int)$argument['lastRun'];
return ((time() - $lastRun) > $this->interval);
}
-
}
diff --git a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
index b46fab19449..64e12fcd251 100644
--- a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
+++ b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
@@ -127,7 +127,6 @@ class MountPublicLinkController extends Controller {
* @return JSONResponse
*/
public function createFederatedShare($shareWith, $token, $password = '') {
-
if (!$this->federatedShareProvider->isOutgoingServer2serverShareEnabled()) {
return new JSONResponse(
['message' => 'This server doesn\'t support outgoing federated shares'],
diff --git a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
index e772d088f24..fe0f1b45e53 100644
--- a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
+++ b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
@@ -136,7 +136,6 @@ class RequestHandlerController extends OCSController {
* @throws OCSException
*/
public function createShare() {
-
$remote = isset($_POST['remote']) ? $_POST['remote'] : null;
$token = isset($_POST['token']) ? $_POST['token'] : null;
$name = isset($_POST['name']) ? $_POST['name'] : null;
@@ -197,7 +196,6 @@ class RequestHandlerController extends OCSController {
* @throws OCSForbiddenException
*/
public function reShare($id) {
-
$token = $this->request->getParam('token', null);
$shareWith = $this->request->getParam('shareWith', null);
$permission = (int)$this->request->getParam('permission', null);
@@ -251,7 +249,6 @@ class RequestHandlerController extends OCSController {
* @throws \OC\HintException
*/
public function acceptShare($id) {
-
$token = isset($_POST['token']) ? $_POST['token'] : null;
$notification = [
@@ -284,7 +281,6 @@ class RequestHandlerController extends OCSController {
* @throws OCSException
*/
public function declineShare($id) {
-
$token = isset($_POST['token']) ? $_POST['token'] : null;
$notification = [
@@ -317,7 +313,6 @@ class RequestHandlerController extends OCSController {
* @throws OCSException
*/
public function unshare($id) {
-
if (!$this->isS2SEnabled()) {
throw new OCSException('Server does not support federated cloud sharing', 503);
}
@@ -353,7 +348,6 @@ class RequestHandlerController extends OCSController {
* @throws OCSBadRequestException
*/
public function revoke($id) {
-
$token = $this->request->getParam('token');
try {
@@ -364,7 +358,6 @@ class RequestHandlerController extends OCSController {
} catch (\Exception $e) {
throw new OCSBadRequestException();
}
-
}
/**
@@ -374,7 +367,6 @@ class RequestHandlerController extends OCSController {
* @return bool
*/
private function isS2SEnabled($incoming = false) {
-
$result = \OCP\App::isEnabled('files_sharing');
if ($incoming) {
@@ -420,7 +412,6 @@ class RequestHandlerController extends OCSController {
* @return array
*/
protected function ncPermissions2ocmPermissions($ncPermissions) {
-
$ocmPermissions = [];
if ($ncPermissions & Constants::PERMISSION_SHARE) {
@@ -437,7 +428,6 @@ class RequestHandlerController extends OCSController {
}
return $ocmPermissions;
-
}
/**
@@ -452,7 +442,6 @@ class RequestHandlerController extends OCSController {
* @throws OCSException
*/
public function move($id) {
-
if (!$this->isS2SEnabled()) {
throw new OCSException('Server does not support federated cloud sharing', 503);
}
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index e1392b7a83a..aaa3e27cfd2 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -58,7 +58,6 @@ use OCP\Share\IShareProvider;
* @package OCA\FederatedFileSharing
*/
class FederatedShareProvider implements IShareProvider {
-
const SHARE_TYPE_REMOTE = 6;
/** @var IDBConnection */
@@ -165,7 +164,6 @@ class FederatedShareProvider implements IShareProvider {
* @throws \Exception
*/
public function create(IShare $share) {
-
$shareWith = $share->getSharedWith();
$itemSource = $share->getNodeId();
$itemType = $share->getNodeType();
@@ -237,7 +235,6 @@ class FederatedShareProvider implements IShareProvider {
$message_t = $this->l->t('File is already shared with %s', [$shareWith]);
throw new \Exception($message_t);
}
-
} else {
$shareId = $this->createFederatedShare($share);
}
@@ -300,7 +297,7 @@ class FederatedShareProvider implements IShareProvider {
$failure = true;
}
- if($failure) {
+ if ($failure) {
$this->removeShareFromTableById($shareId);
$message_t = $this->l->t('Sharing %1$s failed, could not find %2$s, maybe the server is currently unreachable or uses a self-signed certificate.',
[$share->getNode()->getName(), $share->getSharedWith()]);
@@ -308,7 +305,6 @@ class FederatedShareProvider implements IShareProvider {
}
return $shareId;
-
}
/**
@@ -319,7 +315,6 @@ class FederatedShareProvider implements IShareProvider {
* @throws \Exception
*/
protected function askOwnerToReShare($shareWith, IShare $share, $shareId) {
-
$remoteShare = $this->getShareFromExternalShareTable($share);
$token = $remoteShare['share_token'];
$remoteId = $remoteShare['remote_id'];
@@ -409,7 +404,7 @@ class FederatedShareProvider implements IShareProvider {
* We allow updating the permissions of federated shares
*/
$qb = $this->dbConnection->getQueryBuilder();
- $qb->update('share')
+ $qb->update('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())))
->set('permissions', $qb->createNamedParameter($share->getPermissions()))
->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()))
@@ -523,7 +518,7 @@ class FederatedShareProvider implements IShareProvider {
->orderBy('id');
$cursor = $qb->execute();
- while($data = $cursor->fetch()) {
+ while ($data = $cursor->fetch()) {
$children[] = $this->createShareObject($data);
}
$cursor->closeCursor();
@@ -539,7 +534,6 @@ class FederatedShareProvider implements IShareProvider {
* @throws \OC\HintException
*/
public function delete(IShare $share) {
-
list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedWith());
// if the local user is the owner we can send the unShare request directly...
@@ -714,7 +708,7 @@ class FederatedShareProvider implements IShareProvider {
$cursor = $qb->execute();
$shares = [];
- while($data = $cursor->fetch()) {
+ while ($data = $cursor->fetch()) {
$shares[] = $this->createShareObject($data);
}
$cursor->closeCursor();
@@ -767,7 +761,7 @@ class FederatedShareProvider implements IShareProvider {
->execute();
$shares = [];
- while($data = $cursor->fetch()) {
+ while ($data = $cursor->fetch()) {
$shares[] = $this->createShareObject($data);
}
$cursor->closeCursor();
@@ -806,7 +800,7 @@ class FederatedShareProvider implements IShareProvider {
$cursor = $qb->execute();
- while($data = $cursor->fetch()) {
+ while ($data = $cursor->fetch()) {
$shares[] = $this->createShareObject($data);
}
$cursor->closeCursor();
@@ -881,7 +875,6 @@ class FederatedShareProvider implements IShareProvider {
* @throws ShareNotFound
*/
private function createShareObject($data) {
-
$share = new Share($this->rootFolder, $this->userManager);
$share->setId((int)$data['id'])
->setShareType((int)$data['share_type'])
@@ -1119,7 +1112,7 @@ class FederatedShareProvider implements IShareProvider {
);
$cursor = $qb->execute();
- while($data = $cursor->fetch()) {
+ while ($data = $cursor->fetch()) {
try {
$share = $this->createShareObject($data);
} catch (InvalidShare $e) {
diff --git a/apps/federatedfilesharing/lib/Notifications.php b/apps/federatedfilesharing/lib/Notifications.php
index a70e947e3c1..6d11ea65096 100644
--- a/apps/federatedfilesharing/lib/Notifications.php
+++ b/apps/federatedfilesharing/lib/Notifications.php
@@ -94,7 +94,6 @@ class Notifications {
* @throws \OC\ServerNotAvailableException
*/
public function sendRemoteShare($token, $shareWith, $name, $remote_id, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId, $shareType) {
-
list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith);
if ($user && $remote) {
@@ -123,7 +122,6 @@ class Notifications {
\OC_Hook::emit('OCP\Share', 'federated_share_added', ['server' => $remote]);
return true;
}
-
}
return false;
@@ -144,7 +142,6 @@ class Notifications {
* @throws \OC\ServerNotAvailableException
*/
public function requestReShare($token, $id, $shareId, $remote, $shareWith, $permission, $filename) {
-
$fields = [
'shareWith' => $shareWith,
'token' => $token,
@@ -251,7 +248,6 @@ class Notifications {
* @return boolean
*/
public function sendUpdateToRemote($remote, $remoteId, $token, $action, $data = [], $try = 0) {
-
$fields = [
'token' => $token,
'remoteId' => $remoteId
@@ -309,7 +305,6 @@ class Notifications {
* @throws \Exception
*/
protected function tryHttpPostToShareEndpoint($remoteDomain, $urlSuffix, array $fields, $action="share") {
-
if ($this->addressHandler->urlContainProtocol($remoteDomain) === false) {
$remoteDomain = 'https://' . $remoteDomain;
}
@@ -341,7 +336,6 @@ class Notifications {
* @throws \Exception
*/
protected function tryLegacyEndPoint($remoteDomain, $urlSuffix, array $fields) {
-
$result = [
'success' => false,
'result' => '',
@@ -369,7 +363,6 @@ class Notifications {
}
return $result;
-
}
/**
@@ -440,6 +433,5 @@ class Notifications {
}
return false;
-
}
}
diff --git a/apps/federatedfilesharing/lib/Settings/Admin.php b/apps/federatedfilesharing/lib/Settings/Admin.php
index 821421294e5..eb7423a4964 100644
--- a/apps/federatedfilesharing/lib/Settings/Admin.php
+++ b/apps/federatedfilesharing/lib/Settings/Admin.php
@@ -53,7 +53,6 @@ class Admin implements ISettings {
* @return TemplateResponse
*/
public function getForm() {
-
$parameters = [
'internalOnly' => $this->gsConfig->onlyInternalFederation(),
'outgoingServer2serverShareEnabled' => $this->fedShareProvider->isOutgoingServer2serverShareEnabled(),
@@ -85,5 +84,4 @@ class Admin implements ISettings {
public function getPriority() {
return 20;
}
-
}
diff --git a/apps/federatedfilesharing/lib/TokenHandler.php b/apps/federatedfilesharing/lib/TokenHandler.php
index 0e3fe7a049d..3922765aeba 100644
--- a/apps/federatedfilesharing/lib/TokenHandler.php
+++ b/apps/federatedfilesharing/lib/TokenHandler.php
@@ -30,7 +30,6 @@ use OCP\Security\ISecureRandom;
* @package OCA\FederatedFileSharing
*/
class TokenHandler {
-
const TOKEN_LENGTH = 15;
/** @var ISecureRandom */
@@ -56,5 +55,4 @@ class TokenHandler {
ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS);
return $token;
}
-
}
diff --git a/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php
index 8af95e888b4..0e9b9dbed62 100644
--- a/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php
+++ b/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php
@@ -170,7 +170,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
* @since 14.0.0
*/
public function shareReceived(ICloudFederationShare $share) {
-
if (!$this->isS2SEnabled(true)) {
throw new ProviderCouldNotAddShareException('Server does not support federated cloud sharing', '', Http::STATUS_SERVICE_UNAVAILABLE);
}
@@ -205,7 +204,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
}
if ($remote && $token && $name && $owner && $remoteId && $shareWith) {
-
if (!Util::isValidFileName($name)) {
throw new ProviderCouldNotAddShareException('The mountpoint name contains invalid characters.', '', Http::STATUS_BAD_REQUEST);
}
@@ -283,7 +281,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
}
throw new ProviderCouldNotAddShareException('server can not add remote share, missing parameter', '', HTTP::STATUS_BAD_REQUEST);
-
}
/**
@@ -301,7 +298,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
* @since 14.0.0
*/
public function notificationReceived($notificationType, $providerId, array $notification) {
-
switch ($notificationType) {
case 'SHARE_ACCEPTED':
return $this->shareAccepted($providerId, $notification);
@@ -378,7 +374,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
* @throws \OC\HintException
*/
private function shareAccepted($id, array $notification) {
-
if (!$this->isS2SEnabled()) {
throw new ActionNotSupportedException('Server does not support federated cloud sharing');
}
@@ -408,7 +403,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
);
$this->cloudFederationProviderManager->sendNotification($remote, $notification);
-
}
return [];
@@ -450,7 +444,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
*
*/
protected function shareDeclined($id, array $notification) {
-
if (!$this->isS2SEnabled()) {
throw new ActionNotSupportedException('Server does not support federated cloud sharing');
}
@@ -485,7 +478,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
$this->executeDeclineShare($share);
return [];
-
}
/**
@@ -512,7 +504,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
->setObject('files', $fileId, $file)
->setLink($link);
$this->activityManager->publish($event);
-
}
/**
@@ -547,7 +538,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
* @throws BadRequestException
*/
private function unshare($id, array $notification) {
-
if (!$this->isS2SEnabled(true)) {
throw new ActionNotSupportedException("incoming shares disabled!");
}
@@ -572,7 +562,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
$result->closeCursor();
if ($token && $id && !empty($share)) {
-
$remote = $this->cleanupRemote($share['remote']);
$owner = $this->cloudIdManager->getCloudId($share['owner'], $remote);
@@ -639,7 +628,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
* @throws ShareNotFound
*/
protected function reshareRequested($id, array $notification) {
-
if (!isset($notification['sharedSecret'])) {
throw new BadRequestException(['sharedSecret']);
}
@@ -681,7 +669,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
} else {
throw new ProviderCouldNotAddShareException('resharing not allowed for share: ' . $id);
}
-
}
/**
@@ -695,7 +682,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
* @throws BadRequestException
*/
protected function updateResharePermissions($id, array $notification) {
-
if (!isset($notification['sharedSecret'])) {
throw new BadRequestException(['sharedSecret']);
}
@@ -725,7 +711,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
*/
protected function ocmPermissions2ncPermissions(array $ocmPermissions) {
$ncPermissions = 0;
- foreach($ocmPermissions as $permission) {
+ foreach ($ocmPermissions as $permission) {
switch (strtolower($permission)) {
case 'read':
$ncPermissions += Constants::PERMISSION_READ;
@@ -739,7 +725,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
default:
throw new BadRequestException(['permission']);
}
-
}
return $ncPermissions;
@@ -779,7 +764,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
$link = Util::linkToAbsolute('files', 'index.php', $args);
return [$file, $link];
-
}
/**
@@ -836,7 +820,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
* @return bool
*/
private function isS2SEnabled($incoming = false) {
-
$result = $this->appManager->isEnabledForUser('files_sharing');
if ($incoming) {