Skip to content

Commit

Permalink
cleaning
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Aug 13, 2020
1 parent ff2991a commit 9bba102
Show file tree
Hide file tree
Showing 37 changed files with 200 additions and 217 deletions.
18 changes: 14 additions & 4 deletions lib/Activity/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*
*/


namespace OCA\Circles\Activity;

use Exception;
Expand All @@ -39,8 +40,13 @@
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
use OpenCloud\Common\Exceptions\InvalidArgumentError;


/**
* Class Provider
*
* @package OCA\Circles\Activity
*/
class Provider implements IProvider {


Expand Down Expand Up @@ -132,7 +138,6 @@ private function setIcon(IEvent $event, Circle $circle) {
}



/**
* @param IEvent $event
* @param Circle $circle
Expand Down Expand Up @@ -189,10 +194,9 @@ private function parseAsModerator(IEvent $event, Circle $circle, $params) {
* @param Circle $circle
* @param array $params
*
* @throws InvalidArgumentError
* @throws FakeException
*/
private function parseMemberAsMember(IEvent $event, Circle $circle, $params) {

if (!key_exists('member', $params)) {
return;
}
Expand All @@ -210,6 +214,8 @@ private function parseMemberAsMember(IEvent $event, Circle $circle, $params) {
* @param IEvent $event
* @param Circle $circle
* @param array $params
*
* @throws FakeException
*/
private function parseGroupAsModerator(IEvent $event, Circle $circle, $params) {
if (!key_exists('group', $params)) {
Expand All @@ -228,6 +234,8 @@ private function parseGroupAsModerator(IEvent $event, Circle $circle, $params) {
* @param IEvent $event
* @param Circle $circle
* @param array $params
*
* @throws FakeException
*/
private function parseMemberAsModerator(IEvent $event, Circle $circle, $params) {
if (!key_exists('member', $params)) {
Expand All @@ -247,6 +255,8 @@ private function parseMemberAsModerator(IEvent $event, Circle $circle, $params)
* @param IEvent $event
* @param Circle $circle
* @param array $params
*
* @throws FakeException
*/
private function parseLinkAsModerator(IEvent $event, Circle $circle, $params) {

Expand Down
3 changes: 2 additions & 1 deletion lib/Api/Circles.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
namespace OCA\Circles\Api;


use OC;
use OCA\Circles\AppInfo\Application;
use OCA\Circles\Model\Circle;
use OCA\Circles\Model\FederatedLink;
Expand All @@ -47,7 +48,7 @@ class Circles {
* @return Circle
*/
public static function detailsCircle($circleId) {
$app = \OC::$server->query(Application::class);
$app = OC::$server->query(Application::class);
$c = $app->getContainer();

return $c->query(CirclesService::class)
Expand Down
28 changes: 7 additions & 21 deletions lib/Api/v1/Circles.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
namespace OCA\Circles\Api\v1;


use OC;
use OCA\Circles\AppInfo\Application;
use OCA\Circles\Exceptions\ApiVersionIncompatibleException;
use OCA\Circles\Model\Circle;
Expand Down Expand Up @@ -65,10 +66,10 @@ class Circles {
const LEVEL_MODERATOR = Member::LEVEL_MODERATOR;
const LEVEL_ADMIN = Member::LEVEL_ADMIN;
const LEVEL_OWNER = Member::LEVEL_OWNER;


protected static function getContainer() {
$app = \OC::$server->query(Application::class);
$app = OC::$server->query(Application::class);

return $app->getContainer();
}
Expand Down Expand Up @@ -130,7 +131,6 @@ public static function compareVersion($apiVersion) {
* @param string $name
*
* @return Circle
* @throws QueryException
*/
public static function createCircle($type, $name) {
$c = self::getContainer();
Expand All @@ -148,7 +148,6 @@ public static function createCircle($type, $name) {
* @param string $circleUniqueId
*
* @return Member
* @throws QueryException
*/
public static function joinCircle($circleUniqueId) {
$c = self::getContainer();
Expand All @@ -167,7 +166,6 @@ public static function joinCircle($circleUniqueId) {
* @param string $circleUniqueId
*
* @return Member
* @throws QueryException
*/
public static function leaveCircle($circleUniqueId) {
$c = self::getContainer();
Expand Down Expand Up @@ -195,13 +193,12 @@ public static function leaveCircle($circleUniqueId) {
* @param bool $forceAll
*
* @return Circle[]
* @throws QueryException
*/
public static function listCircles($type, $name = '', $level = 0, $userId = '', $forceAll = false) {
$c = self::getContainer();

if ($userId === '') {
$userId = \OC::$server->getUserSession()
$userId = OC::$server->getUserSession()
->getUser()
->getUID();
}
Expand Down Expand Up @@ -261,7 +258,6 @@ public static function joinedCircleIds($userId = '') {
* @param bool $forceAll
*
* @return Circle
* @throws QueryException
*/
public static function detailsCircle($circleUniqueId, $forceAll = false) {
$c = self::getContainer();
Expand All @@ -280,7 +276,6 @@ public static function detailsCircle($circleUniqueId, $forceAll = false) {
* @param array $settings
*
* @return Circle
* @throws QueryException
*/
public static function settingsCircle($circleUniqueId, array $settings) {
$c = self::getContainer();
Expand All @@ -298,7 +293,6 @@ public static function settingsCircle($circleUniqueId, array $settings) {
* @param string $circleUniqueId
*
* @return mixed
* @throws QueryException
*/
public static function destroyCircle($circleUniqueId) {
$c = self::getContainer();
Expand All @@ -319,7 +313,6 @@ public static function destroyCircle($circleUniqueId) {
* @param int $type
*
* @return Member[]
* @throws QueryException
*/
public static function addMember($circleUniqueId, $ident, $type) {
$c = self::getContainer();
Expand All @@ -341,7 +334,6 @@ public static function addMember($circleUniqueId, $ident, $type) {
* @param bool $forceAll
*
* @return Member
* @throws QueryException
*/
public static function getMember($circleUniqueId, $ident, $type, $forceAll = false) {
$c = self::getContainer();
Expand All @@ -362,7 +354,6 @@ public static function getMember($circleUniqueId, $ident, $type, $forceAll = fal
* @param int $type
*
* @return Member[]
* @throws QueryException
*/
public static function removeMember($circleUniqueId, $ident, $type) {
$c = self::getContainer();
Expand All @@ -386,7 +377,6 @@ public static function removeMember($circleUniqueId, $ident, $type) {
* @param int $level
*
* @return Member[]
* @throws QueryException
*/
public static function levelMember($circleUniqueId, $ident, $type, $level) {
$c = self::getContainer();
Expand All @@ -410,7 +400,6 @@ public static function levelMember($circleUniqueId, $ident, $type, $level) {
* @param string $broadcaster
*
* @return mixed
* @throws QueryException
*/
public static function shareToCircle(
$circleUniqueId, $source, $type, array $payload, $broadcaster
Expand All @@ -434,7 +423,6 @@ public static function shareToCircle(
* @param string $circleUniqueId
*
* @return mixed
* @throws QueryException
*/
public static function getSharesFromCircle($circleUniqueId) {
$c = self::getContainer();
Expand All @@ -456,7 +444,6 @@ public static function getSharesFromCircle($circleUniqueId) {
* @param string $remote
*
* @return FederatedLink
* @throws QueryException
*/
public static function linkCircle($circleUniqueId, $remote) {
$c = self::getContainer();
Expand All @@ -476,7 +463,7 @@ public static function linkCircle($circleUniqueId, $remote) {
* @return string
*/
public static function generateLink($circleUniqueId) {
return \OC::$server->getURLGenerator()
return OC::$server->getURLGenerator()
->linkToRoute('circles.Navigation.navigate') . '#' . $circleUniqueId;
}

Expand All @@ -491,7 +478,7 @@ public static function generateLink($circleUniqueId) {
* @return string
*/
public static function generateAbsoluteLink($circleUniqueId) {
return \OC::$server->getURLGenerator()
return OC::$server->getURLGenerator()
->linkToRouteAbsolute('circles.Navigation.navigate') . '#' . $circleUniqueId;
}

Expand All @@ -506,7 +493,7 @@ public static function generateAbsoluteLink($circleUniqueId) {
* @return string
*/
public static function generateRemoteLink(FederatedLink $link) {
return \OC::$server->getURLGenerator()
return OC::$server->getURLGenerator()
->linkToRoute('circles.Navigation.navigate') . '#' . $link->getUniqueId()
. '-' . $link->getToken();
}
Expand Down Expand Up @@ -560,7 +547,6 @@ public static function generateCircleParameter(SharingFrame $frame) {
* @param array $circleUniqueIds
*
* @return string[] array of object ids or empty array if none found
* @throws QueryException
*/
public static function getFilesForCircles($circleUniqueIds) {
$c = self::getContainer();
Expand Down
19 changes: 4 additions & 15 deletions lib/Circles/FileSharingBroadcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
use OCA\FederatedFileSharing\Notifications;
use OCP\AppFramework\QueryException;
use OCP\Defaults;
use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Federation\ICloudIdManager;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
Expand Down Expand Up @@ -79,12 +77,6 @@ class FileSharingBroadcaster implements IBroadcaster {
/** @var IUserManager */
private $userManager;

/** @var ICloudFederationFactory */
private $federationFactory;

/** @var ICloudFederationProviderManager */
private $federationProviderManager;

/** @var ICloudIdManager */
private $federationCloudIdManager;

Expand Down Expand Up @@ -115,6 +107,7 @@ class FileSharingBroadcaster implements IBroadcaster {
/** @var bool */
private $federatedEnabled = false;


/**
* {@inheritdoc}
*/
Expand All @@ -128,8 +121,6 @@ public function init() {
$this->mailer = OC::$server->getMailer();
$this->rootFolder = OC::$server->getLazyRootFolder();
$this->userManager = OC::$server->getUserManager();
$this->federationFactory = OC::$server->getCloudFederationFactory();
$this->federationProviderManager = OC::$server->getCloudFederationProviderManager();
$this->federationCloudIdManager = OC::$server->getCloudIdManager();
$this->logger = OC::$server->getLogger();
$this->urlGenerator = OC::$server->getURLGenerator();
Expand Down Expand Up @@ -348,7 +339,7 @@ private function generateShare($data): IShare {
* @param Circle $circle
* @param IShare $share
* @param string $address
* @param string $token
* @param SharesToken $token
*
* @return bool
*/
Expand All @@ -361,11 +352,11 @@ public function sharedByFederated(Circle $circle, IShare $share, string $address
$sharedByFederatedId = $share->getSharedBy();
if ($this->userManager->userExists($sharedByFederatedId)) {
$cloudId = $this->federationCloudIdManager->getCloudId($sharedByFederatedId, $localUrl);
$sharedByFederatedId = $cloudId->getId();
}
$sharedByFederatedId = $cloudId->getId();
$ownerCloudId = $this->federationCloudIdManager->getCloudId($share->getShareOwner(), $localUrl);

$send = $this->federationNotifications->sendRemoteShare(
return $this->federationNotifications->sendRemoteShare(
$token->getToken(),
$address,
$share->getNode()
Expand All @@ -377,8 +368,6 @@ public function sharedByFederated(Circle $circle, IShare $share, string $address
$sharedByFederatedId,
Share::TYPE_USER
);

return $send;
} catch (\Exception $e) {
$this->logger->logException(
$e, [
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
use OCA\Circles\Exceptions\CommandMissingArgumentException;
use OCA\Circles\Exceptions\FakeException;
use OCP\IL10N;
use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand Down Expand Up @@ -106,6 +105,7 @@ private function listLinkedGroups(InputInterface $input, OutputInterface $output
* @param OutputInterface $output
*
* @throws FakeException
* @throws CommandMissingArgumentException
*/
private function addLinkedGroups(InputInterface $input, OutputInterface $output) {
if ($input->getOption('link') !== true) {
Expand Down
1 change: 1 addition & 0 deletions lib/Controller/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class BaseController extends Controller {
* @param SearchService $searchService
* @param MembersService $membersService
* @param GSUpstreamService $gsUpstreamService
* @param GSDownstreamService $gsDownstreamService
* @param GroupsService $groupsService
* @param SharingFrameService $sharingFrameService
* @param BroadcastService $broadcastService
Expand Down
3 changes: 3 additions & 0 deletions lib/Controller/FederatedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use OC\AppFramework\Http;
use OCA\Circles\Api\v1\Circles;
use OCA\Circles\Exceptions\CircleDoesNotExistException;
use OCA\Circles\Exceptions\MissingKeyInArrayException;
use OCA\Circles\Exceptions\SharingFrameAlreadyExistException;
use OCA\Circles\Model\FederatedLink;
use OCA\Circles\Model\SharingFrame;
Expand Down Expand Up @@ -144,6 +145,7 @@ public function requestedLink($data) {
* @param $data
*
* @return FederatedLink
* @throws MissingKeyInArrayException
*/
private function generateNewLink($data) {
MiscService::mustContains($data, ['token', 'uniqueId', 'sourceName', 'address']);
Expand Down Expand Up @@ -176,6 +178,7 @@ private function generateNewLink($data) {
* @param string $item
*
* @return DataResponse
* @throws Exception
*/
public function receiveFederatedDelivery($apiVersion, $token, $uniqueId, $item) {

Expand Down
2 changes: 2 additions & 0 deletions lib/Controller/GroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
namespace OCA\Circles\Controller;

use Exception;
use OCA\Circles\Exceptions\GSStatusException;
use OCA\Circles\Exceptions\LinkedGroupNotAllowedException;
use OCP\AppFramework\Http\DataResponse;

Expand All @@ -42,6 +43,7 @@ class GroupsController extends BaseController {
*
* @return DataResponse
* @throws LinkedGroupNotAllowedException
* @throws GSStatusException
*/
public function add($uniqueId, $name) {
if (!$this->configService->isLinkedGroupsAllowed()) {
Expand Down
Loading

0 comments on commit 9bba102

Please sign in to comment.