mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-24 23:55:02 +00:00
msgraph: add metadata to users to connect with default calendar
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\CalendarBundle\Command;
|
||||
|
||||
use Chill\CalendarBundle\Synchro\Connector\MSGraph\MachineTokenStorage;
|
||||
use Chill\CalendarBundle\Synchro\Connector\MSGraphRemoteCalendarConnector;
|
||||
use Chill\MainBundle\Repository\UserRepository;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class MapUserCalendarCommand extends Command
|
||||
{
|
||||
private MSGraphRemoteCalendarConnector $remoteCalendarConnector;
|
||||
|
||||
private UserRepository $userRepository;
|
||||
|
||||
public function __construct(MSGraphRemoteCalendarConnector $remoteCalendarConnector)
|
||||
{
|
||||
parent::__construct('chill:calendar:map-user');
|
||||
|
||||
$this->remoteCalendarConnector = $remoteCalendarConnector;
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$limit = 2;
|
||||
|
||||
do {
|
||||
$users = $this->userRepository->findByNotHavingAttribute('ms:graph', $limit);
|
||||
|
||||
foreach ($users as $user) {
|
||||
$usersData = $this->remoteCalendarConnector->getUserByEmail($user->getEmailCanonical());
|
||||
|
||||
$defaultCalendar
|
||||
|
||||
$user->setAttributes(['ms:graph' => [
|
||||
|
||||
]]);
|
||||
}
|
||||
|
||||
} while (count($users) === $limit);
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user