Files
ladill-meet/app/Services/Meet/TeamMemberProvisioner.php
T
isaaccladandCursor a9d3a8bd64
Deploy Ladill Meet / deploy (push) Successful in 47s
Sync email team invites, meeting room fixes, Afia, and org settings.
Publish monorepo meet changes: identity API invites, join/room session fixes,
Afia assistant panel, settings nav, and SSO team provisioning.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 06:45:35 +00:00

56 lines
1.6 KiB
PHP

<?php
namespace App\Services\Meet;
use App\Models\Member;
use App\Models\User;
use App\Services\Identity\IdentityTeamClient;
class TeamMemberProvisioner
{
public function __construct(
protected IdentityTeamClient $identity,
) {}
public function sync(User $user): void
{
Member::query()
->where('user_ref', strtolower((string) $user->email))
->update(['user_ref' => $user->ownerRef()]);
try {
$access = $this->identity->teamAccess($user->ownerRef());
} catch (\Throwable) {
return;
}
foreach ($access as $grant) {
if (($grant['self'] ?? false) || ($grant['full_access'] ?? false)) {
continue;
}
$apps = (array) ($grant['apps'] ?? []);
if (! in_array('meet', $apps, true)) {
continue;
}
$appMeta = (array) data_get($grant, 'metadata.meet', []);
$organizationId = (int) ($appMeta['organization_id'] ?? 0);
if ($organizationId <= 0) {
continue;
}
Member::updateOrCreate(
[
'organization_id' => $organizationId,
'user_ref' => $user->ownerRef(),
],
[
'owner_ref' => (string) ($grant['account'] ?? $user->ownerRef()),
'role' => (string) ($appMeta['role'] ?? 'member'),
'branch_id' => $appMeta['branch_id'] ?? null,
],
);
}
}
}