Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use OCA\Circles\Events\CircleMemberAddedEvent;
use OCA\Circles\Events\MembershipsCreatedEvent;
use OCA\Circles\Events\MembershipsRemovedEvent;
use OCA\Circles\Events\RemovingCircleMemberEvent;
use OCA\Circles\Events\RequestingCircleMemberEvent;
use OCA\Circles\Handlers\WebfingerHandler;
use OCA\Circles\Listeners\DeprecatedListener;
Expand All @@ -50,7 +51,7 @@
use OCA\Circles\Listeners\Examples\ExampleRequestingCircleMember;
use OCA\Circles\Listeners\Files\AddingMember as ListenerFilesAddingMember;
use OCA\Circles\Listeners\Files\MemberAdded as ListenerFilesMemberAdded;
use OCA\Circles\Listeners\Files\MembershipsRemoved as ListenerFilesMembershipsRemoved;
use OCA\Circles\Listeners\Files\RemovingMember as ListenerFilesRemovingMember;
use OCA\Circles\Listeners\GroupCreated;
use OCA\Circles\Listeners\GroupDeleted;
use OCA\Circles\Listeners\GroupMemberAdded;
Expand All @@ -62,13 +63,11 @@
use OCA\Circles\Notification\Notifier;
use OCA\Circles\Service\ConfigService;
use OCA\Circles\Service\DavService;
//use OCA\Files\App as FilesApp;
use OCP\App\ManagerEvent;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\IAppContainer;
use OCP\Files\Config\IMountProviderCollection;
use OCP\Group\Events\GroupCreatedEvent;
use OCP\Group\Events\GroupDeletedEvent;
Expand All @@ -81,6 +80,8 @@
use Symfony\Component\EventDispatcher\GenericEvent;
use Throwable;

//use OCA\Files\App as FilesApp;


require_once __DIR__ . '/../../vendor/autoload.php';

Expand All @@ -107,9 +108,6 @@ class Application extends App implements IBootstrap {
/** @var ConfigService */
private $configService;

/** @var IAppContainer */
private $container;


/**
* Application constructor.
Expand Down Expand Up @@ -143,9 +141,7 @@ public function register(IRegistrationContext $context): void {
// Local Events (for Files/Shares/Notifications management)
$context->registerEventListener(AddingCircleMemberEvent::class, ListenerFilesAddingMember::class);
$context->registerEventListener(CircleMemberAddedEvent::class, ListenerFilesMemberAdded::class);
$context->registerEventListener(
MembershipsRemovedEvent::class, ListenerFilesMembershipsRemoved::class
);
$context->registerEventListener(RemovingCircleMemberEvent::class, ListenerFilesRemovingMember::class);
$context->registerEventListener(
RequestingCircleMemberEvent::class, ListenerNotificationsRequestingMember::class
);
Expand Down
22 changes: 11 additions & 11 deletions lib/Command/CirclesMemberships.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ protected function configure() {
->setDescription('index and display memberships for local and federated users')
->addArgument('userId', InputArgument::OPTIONAL, 'userId to generate memberships', '')
->addOption('display-name', '', InputOption::VALUE_NONE, 'display the displayName')
->addOption('reset', '', InputOption::VALUE_NONE, 'reset memberships')
// ->addOption('reset', '', InputOption::VALUE_NONE, 'reset memberships')
->addOption('all', '', InputOption::VALUE_NONE, 'refresh memberships for all entities')
->addOption(
'type', '', InputOption::VALUE_REQUIRED, 'type of the user',
Expand Down Expand Up @@ -208,11 +208,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$type = Member::parseTypeString($input->getOption('type'));
$federatedUser = $this->federatedUserService->getFederatedUser($userId, (int)$type);

if ($this->input->getOption('reset')) {
$this->membershipsService->resetMemberships($federatedUser->getSingleId());

return 0;
}
// if ($this->input->getOption('reset')) {
// $this->membershipsService->resetMemberships($federatedUser->getSingleId());
//
// return 0;
// }

$output->writeln('Id: <info>' . $federatedUser->getUserId() . '</info>');
$output->writeln('Instance: <info>' . $federatedUser->getInstance() . '</info>');
Expand Down Expand Up @@ -361,11 +361,11 @@ public function displayLeaf(SimpleDataStore $data, int $lineNumber): string {
* @throws RequestBuilderException
*/
private function manageAllMemberships() {
if ($this->input->getOption('reset')) {
$this->membershipsService->resetMemberships('', true);

return;
}
// if ($this->input->getOption('reset')) {
// $this->membershipsService->resetMemberships('', true);
//
// return;
// }

$this->federatedUserService->bypassCurrentUserCondition(true);

Expand Down
29 changes: 29 additions & 0 deletions lib/Db/ShareTokenRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ public function save(ShareToken $token): void {
}


/**
* @param ShareToken $shareToken
*
* @return ShareToken
* @throws ShareTokenNotFoundException
*/
public function search(ShareToken $shareToken): ShareToken {
$qb = $this->getTokenSelectSql();
$qb->limitInt('share_id', $shareToken->getshareId());
$qb->limitToCircleId($shareToken->getCircleId());
$qb->limitToSingleId($shareToken->getSingleId());

return $this->getItemFromRequest($qb);
}


/**
* @param string $token
*
Expand All @@ -78,5 +94,18 @@ public function getByToken(string $token): ShareToken {
return $this->getItemFromRequest($qb);
}


/**
* @param string $singleId
* @param string $circleId
*/
public function removeTokens(string $singleId, string $circleId) {
$qb = $this->getTokenDeleteSql();
$qb->limitToSingleId($singleId);
$qb->limitToCircleId($circleId);

$qb->execute();
}

}

23 changes: 11 additions & 12 deletions lib/Db/ShareWrapperRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public function getSharesToCircle(

$qb->leftJoinCircle(CoreQueryBuilder::SHARE, null, 'share_with');

// TODO: filter direct-shares ?
$aliasUpstreamMembership =
$qb->generateAlias(CoreQueryBuilder::SHARE, CoreQueryBuilder::UPSTREAM_MEMBERSHIPS);
$qb->limitToInheritedMemberships(CoreQueryBuilder::SHARE, $circleId, 'share_with');
Expand All @@ -176,20 +177,18 @@ public function getSharesToCircle(
// $qb->limitToInitiator(CoreRequestBuilder::SHARE, $shareRecipient, 'share_with');
// }

$qb->leftJoinInheritedMembers(
$aliasUpstreamMembership,
'circle_id',
$qb->generateAlias(CoreQueryBuilder::SHARE, CoreQueryBuilder::INHERITED_BY)
);

$aliasMembership = $qb->generateAlias($aliasUpstreamMembership, CoreQueryBuilder::MEMBERSHIPS);
$qb->leftJoinFileCache(CoreQueryBuilder::SHARE);
$qb->leftJoinShareChild(CoreQueryBuilder::SHARE, $aliasMembership);
// TODO: add shareInitiator and shareRecipient to filter the request
if (!is_null($shareRecipient) || $completeDetails) {
$qb->leftJoinInheritedMembers(
$aliasUpstreamMembership,
'circle_id',
$qb->generateAlias(CoreQueryBuilder::SHARE, CoreQueryBuilder::INHERITED_BY)
);

if (!is_null($shareInitiator)) {
}
$aliasMembership = $qb->generateAlias($aliasUpstreamMembership, CoreQueryBuilder::MEMBERSHIPS);
$qb->leftJoinFileCache(CoreQueryBuilder::SHARE);
$qb->leftJoinShareChild(CoreQueryBuilder::SHARE, $aliasMembership);

if ($completeDetails) {
$qb->generateGroupBy(
self::$tables[self::TABLE_MEMBERSHIP],
$aliasMembership,
Expand Down
2 changes: 1 addition & 1 deletion lib/Events/AddingCircleMemberEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
* This is a good place if anything needs to be executed when a new member have been added to a Circle.
*
* If anything needs to be managed on the master instance of the Circle (ie. CircleMemberAddedEvent), please use:
* $event->getFederatedEvent()->addResult(string $key, array $data);
* $event->getFederatedEvent()->setResultEntry(string $key, array $data);
*
* @package OCA\Circles\Events
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Events/CreatingCircleEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* This is a good place if anything needs to be executed when a new Circle has been created.
*
* If anything needs to be managed on the master instance of the Circle (ie. CircleCreatedEvent), please use:
* $event->getFederatedEvent()->addResult(string $key, array $data);
* $event->getFederatedEvent()->setResultEntry(string $key, array $data);
*
* @package OCA\Circles\Events
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Events/DestroyingCircleEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* This is a good place if anything needs to be executed when a Circle has been destroyed.
*
* If anything needs to be managed on the master instance of the Circle (ie. CircleDestroyedEvent), please use:
* $event->getFederatedEvent()->addResult(string $key, array $data);
* $event->getFederatedEvent()->setResultEntry(string $key, array $data);
* *
* @package OCA\Circles\Events
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Events/EditingCircleEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
* This is a good place if anything needs to be executed when a circle is edited.
*
* If anything needs to be managed on the master instance of the Circle (ie. CircleEditedEvent), please use:
* $event->getFederatedEvent()->addResult(string $key, array $data);
* $event->getFederatedEvent()->setResultEntry(string $key, array $data);
*
* @package OCA\Circles\Events
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Events/EditingCircleMemberEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
*
* If anything needs to be managed on the master instance of the Circle (ie. CircleMemberEditedEvent), please
* use:
* $event->getFederatedEvent()->addResult(string $key, array $data);
* $event->getFederatedEvent()->setResultEntry(string $key, array $data);
*
* @package OCA\Circles\Events
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Events/RemovingCircleMemberEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
* This is a good place if anything needs to be executed when a member have been removed from a Circle.
*
* If anything needs to be managed on the master instance of the Circle (ie. CircleMemberRemovedEvent), please use:
* $event->getFederatedEvent()->addResult(string $key, array $data);
* $event->getFederatedEvent()->setResultEntry(string $key, array $data);
*
* @package OCA\Circles\Events
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Events/RequestingCircleMemberEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* This is a good place if anything needs to be executed when a member requests or is invited to a Circle.
*
* If anything needs to be managed on the master instance of the Circle (ie. CircleMemberRequestedEvent), please use:
* $event->getFederatedEvent()->addResult(string $key, array $data);
* $event->getFederatedEvent()->setResultEntry(string $key, array $data);
*
* @package OCA\Circles\Events
*/
Expand Down
45 changes: 45 additions & 0 deletions lib/Exceptions/ShareTokenAlreadyExistException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);


/**
* Circles - Bring cloud-users closer together.
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <[email protected]>
* @copyright 2021
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Circles\Exceptions;


use Exception;


/**
* Class ShareTokenAlreadyExistException
*
* @package OCA\Circles\Exceptions
*/
class ShareTokenAlreadyExistException extends Exception {

}

1 change: 1 addition & 0 deletions lib/FederatedItems/SingleMemberAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ private function memberIsMailbox(
}

try {

$template = $this->generateMailExitingShares($author, $circle->getName());
$this->fillMailExistingShares($template, $links);
$this->sendMailExistingShares($template, $author, $recipient);
Expand Down
Loading