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
50 changes: 14 additions & 36 deletions lib/FederatedItems/CircleCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace OCA\Circles\FederatedItems;

use OC\User\NoUserException;
use OCA\Circles\Db\CircleRequest;
use OCA\Circles\Db\MemberRequest;
use OCA\Circles\Exceptions\CircleNotFoundException;
Expand All @@ -25,6 +26,7 @@
use OCA\Circles\Model\Federated\FederatedEvent;
use OCA\Circles\Service\CircleService;
use OCA\Circles\Service\EventService;
use OCA\Circles\Service\MaintenanceService;
use OCA\Circles\Service\MembershipService;
use OCA\Circles\Tools\Traits\TDeserialize;

Expand All @@ -40,44 +42,14 @@ class CircleCreate implements
IFederatedItemMustBeInitializedLocally {
use TDeserialize;


/** @var CircleRequest */
private $circleRequest;

/** @var MemberRequest */
private $memberRequest;

/** @var CircleService */
private $circleService;

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

/** @var EventService */
private $eventService;


/**
* CircleCreate constructor.
*
* @param CircleRequest $circleRequest
* @param MemberRequest $memberRequest
* @param CircleService $circleService
* @param MembershipService $membershipService
* @param EventService $eventService
*/
public function __construct(
CircleRequest $circleRequest,
MemberRequest $memberRequest,
CircleService $circleService,
MembershipService $membershipService,
EventService $eventService
private CircleRequest $circleRequest,
private MemberRequest $memberRequest,
private CircleService $circleService,
private MembershipService $membershipService,
private MaintenanceService $maintenanceService,
private EventService $eventService,
) {
$this->circleRequest = $circleRequest;
$this->memberRequest = $memberRequest;
$this->circleService = $circleService;
$this->membershipService = $membershipService;
$this->eventService = $eventService;
}


Expand Down Expand Up @@ -126,6 +98,12 @@ public function manage(FederatedEvent $event): void {
$this->membershipService->onUpdate($owner->getSingleId());
$this->membershipService->updatePopulation($circle);

try {
$this->maintenanceService->updateDisplayName($owner);
} catch (NoUserException) {
// ignoreable
}

$this->eventService->circleCreating($event);
}

Expand Down
14 changes: 13 additions & 1 deletion lib/FederatedItems/SingleMemberAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace OCA\Circles\FederatedItems;

use OC\User\NoUserException;
use OCA\Circles\Db\MemberRequest;
use OCA\Circles\Exceptions\CircleNotFoundException;
use OCA\Circles\Exceptions\FederatedItemBadRequestException;
Expand Down Expand Up @@ -46,6 +47,7 @@
use OCA\Circles\Service\ConfigService;
use OCA\Circles\Service\EventService;
use OCA\Circles\Service\FederatedUserService;
use OCA\Circles\Service\MaintenanceService;
use OCA\Circles\Service\MemberService;
use OCA\Circles\Service\MembershipService;
use OCA\Circles\Service\RemoteStreamService;
Expand Down Expand Up @@ -79,7 +81,8 @@ public function __construct(
protected MemberService $memberService,
protected MembershipService $membershipService,
protected EventService $eventService,
protected ConfigService $configService
protected ConfigService $configService,
protected MaintenanceService $maintenanceService,
) {
}

Expand Down Expand Up @@ -235,6 +238,15 @@ protected function generateMember(FederatedEvent $event, Circle $circle, Member
// of the event to Federated RemoteInstance for their first member.
$this->memberRequest->insertOrUpdate($member);

try {
$displayName = $this->maintenanceService->updateDisplayName($member);
if ($displayName !== '') {
$member->setDisplayName($displayName);
}
} catch (NoUserException) {
// ignoreable
}

return $member;
}

Expand Down
Loading