|
|
|
|
@ -20,6 +20,7 @@ use OCP\Interaction\InteractionReceiver; |
|
|
|
|
use OCP\Interaction\Receivers\CircleReceiver; |
|
|
|
|
use OCP\IUser; |
|
|
|
|
use OCP\L10N\IFactory; |
|
|
|
|
use OCP\Server; |
|
|
|
|
use OCP\Share\IShare; |
|
|
|
|
use OCP\Sharing\Icon\ShareIconSVG; |
|
|
|
|
use OCP\Sharing\Icon\ShareIconURL; |
|
|
|
|
@ -34,15 +35,21 @@ use OCP\Teams\Team; |
|
|
|
|
* @template-implements IEventListener<DestroyingCircleEvent> |
|
|
|
|
*/ |
|
|
|
|
final class TeamShareRecipientType extends AShareRecipientTypeSearchCollaborator implements IEventListener { |
|
|
|
|
private ?ITeamManager $teamManager = null; |
|
|
|
|
|
|
|
|
|
public function __construct( |
|
|
|
|
IEventDispatcher $eventDispatcher, |
|
|
|
|
private readonly IDBConnection $dbConnection, |
|
|
|
|
private readonly ITeamManager $teamManager, |
|
|
|
|
private readonly ISharingManager $manager, |
|
|
|
|
) { |
|
|
|
|
$eventDispatcher->addServiceListener(DestroyingCircleEvent::class, self::class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// CirclesManager class is not registered yet when the class is instantiated. |
|
|
|
|
private function getTeamManager(): ITeamManager { |
|
|
|
|
return $this->teamManager ??= Server::get(ITeamManager::class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[\Override] |
|
|
|
|
public function getDisplayName(IFactory $l10nFactory): string { |
|
|
|
|
return $l10nFactory->get(Application::APP_ID)->t('Team'); |
|
|
|
|
@ -50,7 +57,7 @@ final class TeamShareRecipientType extends AShareRecipientTypeSearchCollaborator |
|
|
|
|
|
|
|
|
|
#[\Override] |
|
|
|
|
public function validateRecipient(string $recipient): bool { |
|
|
|
|
return $this->teamManager->getTeam($recipient) instanceof Team; |
|
|
|
|
return $this->getTeamManager()->getTeam($recipient) instanceof Team; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[\Override] |
|
|
|
|
@ -59,12 +66,12 @@ final class TeamShareRecipientType extends AShareRecipientTypeSearchCollaborator |
|
|
|
|
return []; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return array_map(static fn (Team $team): string => $team->getId(), $this->teamManager->getTeamsForUser($currentUser->getUID())); |
|
|
|
|
return array_map(static fn (Team $team): string => $team->getId(), $this->getTeamManager()->getTeamsForUser($currentUser->getUID())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[\Override] |
|
|
|
|
public function getRecipientDisplayName(string $recipient): ?string { |
|
|
|
|
return $this->teamManager->getTeam($recipient)?->getDisplayName(); |
|
|
|
|
return $this->getTeamManager()->getTeam($recipient)?->getDisplayName(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[\Override] |
|
|
|
|
|