mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 23:23:51 +00:00
msgraph: add metadata to users to connect with default calendar
This commit is contained in:
@@ -40,13 +40,10 @@ class AzureGetMachineAccessTokenCommand extends Command
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->addOption('tenant', 't', InputOption::VALUE_OPTIONAL, 'the tenant, usually the application name', 'common');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->azure->tenant = $input->getOption('tenant');
|
||||
$this->azure->scope = ['https://graph.microsoft.com/.default'];
|
||||
$authorizationUrl = explode('?', $this->azure->getAuthorizationUrl(['prompt' => 'consent']));
|
||||
// replace the first part by the admin consent authorization url
|
||||
|
@@ -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