Skip to content

Commit

Permalink
Better 'creation_activity' option handling
Browse files Browse the repository at this point in the history
Signed-off-by: Tortue Torche <tortuetorche@users.noreply.github.com>
  • Loading branch information
tortuetorche committed Apr 9, 2020
1 parent 5a0e5bb commit 7ffe303
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions lib/Service/EventsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,22 @@ public function __construct(
* @param Circle $circle
*/
public function onCircleCreation(Circle $circle) {
if ($this->configService->getAppValue(ConfigService::CIRCLES_ACTIVITY_ON_CREATION) !== '1'
|| ($circle->getType() !== Circle::CIRCLES_PUBLIC
&& $circle->getType() !== Circle::CIRCLES_CLOSED)) {
if ($circle->getType() !== Circle::CIRCLES_PUBLIC
&& $circle->getType() !== Circle::CIRCLES_CLOSED) {
return;
}

$event = $this->generateEvent('circles_as_non_member');
$event->setSubject('circle_create', ['circle' => json_encode($circle)]);
if ($this->configService->getAppValue(ConfigService::CIRCLES_ACTIVITY_ON_CREATION) === '1') {
$event = $this->generateEvent('circles_as_non_member');
$event->setSubject('circle_create', ['circle' => json_encode($circle)]);

$this->userManager->callForSeenUsers(
function($user) use ($event) {
/** @var IUser $user */
$this->publishEvent($event, [$user]);
}
);
$this->userManager->callForSeenUsers(
function($user) use ($event) {
/** @var IUser $user */
$this->publishEvent($event, [$user]);
}
);
}

$this->dispatch('\OCA\Circles::onCircleCreation', ['circle' => $circle]);
}
Expand Down Expand Up @@ -213,6 +214,7 @@ public function onMemberNew(Circle $circle, Member $member) {
)
)
);

$this->dispatch('\OCA\Circles::onMemberNew', ['circle' => $circle, 'member' => $member]);

$this->notificationOnMemberNew($circle, $member);
Expand Down Expand Up @@ -340,6 +342,7 @@ public function onMemberLeaving(Circle $circle, Member $member) {
)
)
);

$this->dispatch('\OCA\Circles::onMemberLeaving', ['circle' => $circle, 'member' => $member]);

$this->deleteNotification('membership', $member->getMemberId());
Expand Down

0 comments on commit 7ffe303

Please sign in to comment.