Files
ladill-events/app/Services/Meet/EventMeetAccessService.php
T
isaaccladandCursor 05a6be7efe
Deploy Ladill Events / deploy (push) Successful in 41s
Complete Events–Meet integration phases 2–5.
Programme sync to Meet rooms, wallet-billed mass comms, webhook lifecycle updates, and registration access bridge with join-window gating on public pages.

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

76 lines
2.2 KiB
PHP

<?php
namespace App\Services\Meet;
use App\Models\QrCode;
use App\Models\QrEventRegistration;
use Illuminate\Support\Facades\Log;
class EventMeetAccessService
{
public function syncRegistration(QrEventRegistration $registration): void
{
$event = $registration->qrCode;
if (! $event || $event->type !== QrCode::TYPE_EVENT) {
return;
}
$format = (string) ($event->content()['format'] ?? 'in_person');
if (! in_array($format, ['virtual', 'hybrid'], true)) {
return;
}
if ((string) config('meet.key', '') === '' || ! $registration->attendee_email) {
return;
}
$ownerRef = (string) $event->user->public_id;
$client = MeetClient::for($ownerRef);
foreach ((array) ($event->content()['virtual_sessions'] ?? []) as $session) {
if (! is_array($session)) {
continue;
}
$roomUuid = trim((string) ($session['meet_room_uuid'] ?? ''));
if ($roomUuid === '') {
continue;
}
try {
$client->updateRoom($roomUuid, [
'invite_emails' => [$registration->attendee_email],
]);
} catch (\Throwable $e) {
Log::warning('Events Meet invite failed', [
'registration_id' => $registration->id,
'room_uuid' => $roomUuid,
'error' => $e->getMessage(),
]);
}
}
$metadata = (array) ($registration->metadata ?? []);
$metadata['meet_invited_at'] = now()->toIso8601String();
$registration->update(['metadata' => $metadata]);
}
public function isJoinWindowOpen(array $session, int $minutesBefore = 15): bool
{
$scheduled = trim((string) ($session['scheduled_at'] ?? ''));
if ($scheduled === '') {
return true;
}
try {
$start = \Carbon\Carbon::parse($scheduled);
} catch (\Throwable) {
return true;
}
$duration = max(15, (int) ($session['duration_minutes'] ?? 60));
return now()->between($start->copy()->subMinutes($minutesBefore), $start->copy()->addMinutes($duration));
}
}