Skip to content

Commit

Permalink
You can now add members in personal circles when `skip_invitation_t…
Browse files Browse the repository at this point in the history
…o_closed_circles` option is enabled

Fix nextcloud#382 and
nextcloud#360

Signed-off-by: Tortue Torche <tortuetorche@users.noreply.github.com>
  • Loading branch information
tortuetorche committed Apr 1, 2020
1 parent 5e252d6 commit 4db92be
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
19 changes: 17 additions & 2 deletions lib/Activity/ProviderParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
use OCA\Circles\Model\FederatedLink;
use OCA\Circles\Model\Member;
use OCA\Circles\Service\MiscService;
use OCA\Circles\Service\ConfigService;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\IL10N;
use OCP\IURLGenerator;

class ProviderParser {


/** @var MiscService */
protected $miscService;

Expand All @@ -52,13 +52,28 @@ class ProviderParser {
/** @var IManager */
protected $activityManager;

/** @var ConfigService */
protected $configService;

/**
* @param IURLGenerator $url
* @param IManager $activityManager
* @param IL10N $l10n
* @param MiscService $miscService
* @param ConfigService $configService
*/
public function __construct(
IURLGenerator $url, IManager $activityManager, IL10N $l10n, MiscService $miscService
IURLGenerator $url,
IManager $activityManager,
IL10N $l10n,
MiscService $miscService,
ConfigService $configService
) {
$this->url = $url;
$this->activityManager = $activityManager;
$this->l10n = $l10n;
$this->miscService = $miscService;
$this->configService = $configService;
}


Expand Down
8 changes: 6 additions & 2 deletions lib/Activity/ProviderSubjectMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public function parseSubjectMemberJoin(IEvent $event, Circle $circle, Member $me
* @throws FakeException
*/
private function parseSubjectMemberJoinClosedCircle(IEvent $event, Circle $circle, Member $member) {
if ($circle->getType() !== Circle::CIRCLES_CLOSED) {
if ($circle->getType() !== Circle::CIRCLES_CLOSED ||
$this->configService->isInvitationSkipped()
) {
return;
}

Expand Down Expand Up @@ -141,7 +143,9 @@ private function parseSubjectMemberAddNotLocalMember(IEvent $event, Circle $circ
* @throws FakeException
*/
private function parseSubjectMemberAddClosedCircle(IEvent $event, Circle $circle, Member $member) {
if ($circle->getType() !== Circle::CIRCLES_CLOSED) {
if ($circle->getType() !== Circle::CIRCLES_CLOSED ||
$this->configService->isInvitationSkipped()
) {
return;
}

Expand Down
3 changes: 1 addition & 2 deletions lib/Model/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function inviteToCircle($circleType) {
public function joinCircle($circleType) {

switch ($circleType) {
case Circle::CIRCLES_PERSONAL:
case Circle::CIRCLES_SECRET:
case Circle::CIRCLES_PUBLIC:
return $this->addMemberToCircle();
Expand Down Expand Up @@ -264,5 +265,3 @@ public function hasToBeInviteAble() {
}

}


0 comments on commit 4db92be

Please sign in to comment.