Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
maintain memberships once a week
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed Jan 22, 2022
commit 9f34aa03f71d8a93231c9a87d2191b77b1024af8
27 changes: 27 additions & 0 deletions lib/Service/MaintenanceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ class MaintenanceService {
/** @var FederatedUserService */
private $federatedUserService;

/** @var MembershipService */
private $membershipService;

/** @var EventWrapperService */
private $eventWrapperService;

Expand All @@ -99,6 +102,7 @@ class MaintenanceService {
* @param ShareWrapperRequest $shareWrapperRequest
* @param SyncService $syncService
* @param FederatedUserService $federatedUserService
* @param MembershipService $membershipService
* @param EventWrapperService $eventWrapperService
* @param CircleService $circleService
* @param ConfigService $configService
Expand All @@ -110,6 +114,7 @@ public function __construct(
ShareWrapperRequest $shareWrapperRequest,
SyncService $syncService,
FederatedUserService $federatedUserService,
MembershipService $membershipService,
EventWrapperService $eventWrapperService,
CircleService $circleService,
ConfigService $configService
Expand All @@ -121,6 +126,7 @@ public function __construct(
$this->syncService = $syncService;
$this->federatedUserService = $federatedUserService;
$this->eventWrapperService = $eventWrapperService;
$this->membershipService = $membershipService;
$this->circleService = $circleService;
$this->configService = $configService;
}
Expand Down Expand Up @@ -257,6 +263,12 @@ private function runMaintenance4(): void {
* every week
*/
private function runMaintenance5(): void {
try {
$this->output('Update memberships');
$this->updateAllMemberships();
} catch (Exception $e) {
}

// try {
// $this->output('refresh displayNames older than 7d');
// // $this->refreshOldDisplayNames();
Expand Down Expand Up @@ -329,6 +341,21 @@ function (ShareWrapper $share) {
}


/**
* @throws InitiatorNotFoundException
* @throws RequestBuilderException
*/
private function updateAllMemberships(): void {
$probe = new CircleProbe();
$probe->includeSystemCircles()
->includeSingleCircles()
->includePersonalCircles();

foreach ($this->circleService->getCircles($probe) as $circle) {
$this->membershipService->manageMemberships($circle->getSingleId());
}
}

/**
* @throws RequestBuilderException
* @throws InitiatorNotFoundException
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/MembershipService.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ private function createNewMemberships(array $memberships, array $known): array {
if ($item->getLevel() !== $membership->getLevel()) {
$this->membershipRequest->update($membership);
$new[] = $item;
} else if ($item->getInheritancePath() !== $membership->getInheritancePath()) {
} elseif ($item->getInheritancePath() !== $membership->getInheritancePath()) {
$this->membershipRequest->update($membership);
}
} catch (ItemNotFoundException $e) {
Expand Down