Atualização
This commit is contained in:
0
.editorconfig
Normal file → Executable file
0
.editorconfig
Normal file → Executable file
0
.env.example
Normal file → Executable file
0
.env.example
Normal file → Executable file
0
.gitattributes
vendored
Normal file → Executable file
0
.gitattributes
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
@@ -19,7 +19,10 @@ class m365_grupos implements ShouldQueue
|
||||
* Create a new job instance.
|
||||
*/
|
||||
protected string $accessToken;
|
||||
public function __construct(public int $id) {}
|
||||
|
||||
public function __construct(public int $id)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
@@ -27,9 +30,9 @@ class m365_grupos implements ShouldQueue
|
||||
public function handle(): void
|
||||
{
|
||||
$this->authenticate();
|
||||
$grupos = Http::withToken($this->accessToken)->get('https://graph.microsoft.com/v1.0/groups?$select=id,displayName,description,groupTypes,securityEnabled,createdDateTime,mail');
|
||||
$datagrupos = $this->grupos();
|
||||
|
||||
foreach ($grupos['value'] as $grupo) {
|
||||
foreach ($datagrupos as $grupo) {
|
||||
if (in_array('Unified', $grupo['groupTypes'] ?? [])) {
|
||||
$grouptype = 'M365';
|
||||
} elseif (!empty($grupo['securityEnabled'])) {
|
||||
@@ -61,10 +64,10 @@ class m365_grupos implements ShouldQueue
|
||||
"https://login.microsoftonline.com/{$cred->id_tenant}/oauth2/v2.0/token",
|
||||
[
|
||||
'form_params' => [
|
||||
'client_id' => $cred->id_client,
|
||||
'client_id' => $cred->id_client,
|
||||
'client_secret' => $cred->id_secret,
|
||||
'grant_type' => 'client_credentials',
|
||||
'scope' => 'https://graph.microsoft.com/.default',
|
||||
'grant_type' => 'client_credentials',
|
||||
'scope' => 'https://graph.microsoft.com/.default',
|
||||
],
|
||||
]
|
||||
);
|
||||
@@ -72,4 +75,28 @@ class m365_grupos implements ShouldQueue
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
$this->accessToken = $data['access_token'];
|
||||
}
|
||||
|
||||
protected function grupos(): array
|
||||
{
|
||||
$grupos = [];
|
||||
$url = 'https://graph.microsoft.com/v1.0/groups?$top=100&$select=id,displayName,description,groupTypes,securityEnabled,createdDateTime,mail';
|
||||
|
||||
do {
|
||||
|
||||
$response = Http::withUrlParameters([
|
||||
'Accept' => 'application/json',
|
||||
])->withToken($this->accessToken)->get($url);
|
||||
|
||||
$data = json_decode($response->body(), true);
|
||||
|
||||
foreach ($data['value'] as $grupo) {
|
||||
$grupos[] = $grupo;
|
||||
}
|
||||
|
||||
|
||||
$url = $data['@odata.nextLink'] ?? null;
|
||||
} while ($url);
|
||||
|
||||
return $grupos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class m365_users implements ShouldQueue
|
||||
'displayName' => $usuario['displayName'],
|
||||
'upn' => $usuario['userPrincipalName'],
|
||||
'primarySmtp' => $usuario['mail'],
|
||||
'principalSource' => "graph",
|
||||
'principalSource' => 'microsoftGraph',
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ class m365_users implements ShouldQueue
|
||||
protected function usuarios(): array
|
||||
{
|
||||
$usuarios = [];
|
||||
$url = 'https://graph.microsoft.com/v1.0/users';
|
||||
$url = 'https://graph.microsoft.com/v1.0/users?$top=100';
|
||||
|
||||
do {
|
||||
|
||||
|
||||
@@ -24,5 +24,6 @@ class clientes_usuarios extends Model
|
||||
'displayName',
|
||||
'upn',
|
||||
'primarySmtp',
|
||||
'principalSource'
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('clientes_grupos', function (Blueprint $table) {
|
||||
$table->longText('description')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('clientes_grupos', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -2,7 +2,11 @@
|
||||
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Schedule;
|
||||
|
||||
Artisan::command('inspire', function () {
|
||||
$this->comment(Inspiring::quote());
|
||||
})->purpose('Display an inspiring quote');
|
||||
|
||||
Schedule::command('sincronismo-clientes:all')->dailyAt('10:00');
|
||||
Schedule::command('sincronismo-clientes:all')->dailyAt('18:00');
|
||||
Reference in New Issue
Block a user