Fix Meet programme sync when linking an existing room.
Deploy Ladill Events / deploy (push) Successful in 37s
Deploy Ladill Events / deploy (push) Successful in 37s
PATCH the pre-linked room by UUID so programme_snapshot lands on the room users join instead of creating a duplicate. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -78,23 +78,29 @@ class EventMeetSyncService
|
|||||||
$settings['panel_discussions'] = true;
|
$settings['panel_discussions'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$roomPayload = [
|
||||||
|
'title' => $title,
|
||||||
|
'description' => trim((string) ($content['description'] ?? '')) ?: null,
|
||||||
|
'type' => $roomType,
|
||||||
|
'scheduled_at' => $scheduledAt,
|
||||||
|
'duration_minutes' => max(15, (int) ($session['duration_minutes'] ?? 60)),
|
||||||
|
'timezone' => config('app.timezone', 'UTC'),
|
||||||
|
'settings' => $settings,
|
||||||
|
'invite_emails' => $inviteEmails,
|
||||||
|
'source' => [
|
||||||
|
'app' => 'events',
|
||||||
|
'entity_type' => 'virtual_session',
|
||||||
|
'entity_id' => $sessionId,
|
||||||
|
'event_id' => (string) $event->id,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$existingRoomUuid = trim((string) ($session['meet_room_uuid'] ?? ''));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$result = $client->upsertRoom([
|
$result = $existingRoomUuid !== ''
|
||||||
'title' => $title,
|
? $client->updateRoom($existingRoomUuid, $roomPayload)
|
||||||
'description' => trim((string) ($content['description'] ?? '')) ?: null,
|
: $client->upsertRoom($roomPayload);
|
||||||
'type' => $roomType,
|
|
||||||
'scheduled_at' => $scheduledAt,
|
|
||||||
'duration_minutes' => max(15, (int) ($session['duration_minutes'] ?? 60)),
|
|
||||||
'timezone' => config('app.timezone', 'UTC'),
|
|
||||||
'settings' => $settings,
|
|
||||||
'invite_emails' => $inviteEmails,
|
|
||||||
'source' => [
|
|
||||||
'app' => 'events',
|
|
||||||
'entity_type' => 'virtual_session',
|
|
||||||
'entity_id' => $sessionId,
|
|
||||||
'event_id' => (string) $event->id,
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::warning('Events Meet sync failed', [
|
Log::warning('Events Meet sync failed', [
|
||||||
'event_id' => $event->id,
|
'event_id' => $event->id,
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ class ServiceMeetLinkTest extends TestCase
|
|||||||
'room' => ['uuid' => 'room-uuid-123'],
|
'room' => ['uuid' => 'room-uuid-123'],
|
||||||
'join_url' => 'https://meet.ladill.com/r/room-uuid-123',
|
'join_url' => 'https://meet.ladill.com/r/room-uuid-123',
|
||||||
], 201),
|
], 201),
|
||||||
|
config('meet.url').'/rooms/*' => Http::response([
|
||||||
|
'room' => ['uuid' => 'room-uuid-123'],
|
||||||
|
'join_url' => 'https://meet.ladill.com/r/room-uuid-123',
|
||||||
|
], 200),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->owner = User::factory()->create(['public_id' => 'usr_meet_link']);
|
$this->owner = User::factory()->create(['public_id' => 'usr_meet_link']);
|
||||||
@@ -87,4 +91,71 @@ class ServiceMeetLinkTest extends TestCase
|
|||||||
$sessions = $event->fresh()->content()['virtual_sessions'];
|
$sessions = $event->fresh()->content()['virtual_sessions'];
|
||||||
$this->assertSame('room-uuid-123', $sessions[0]['meet_room_uuid'] ?? null);
|
$this->assertSame('room-uuid-123', $sessions[0]['meet_room_uuid'] ?? null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_link_room_patches_existing_meet_room_with_programme_snapshot(): void
|
||||||
|
{
|
||||||
|
$programme = QrCode::create([
|
||||||
|
'user_id' => $this->owner->id,
|
||||||
|
'short_code' => 'prog-link-1',
|
||||||
|
'type' => QrCode::TYPE_ITINERARY,
|
||||||
|
'label' => 'Summit programme',
|
||||||
|
'payload' => [
|
||||||
|
'content' => [
|
||||||
|
'title' => 'Summit programme',
|
||||||
|
'days' => [
|
||||||
|
[
|
||||||
|
'label' => 'Day 1',
|
||||||
|
'items' => [
|
||||||
|
['ref' => 'item-1', 'time' => '09:00', 'title' => 'Opening keynote', 'host' => 'Alex'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'style' => [],
|
||||||
|
],
|
||||||
|
'is_active' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$event = QrCode::create([
|
||||||
|
'user_id' => $this->owner->id,
|
||||||
|
'short_code' => 'evt-prog-link',
|
||||||
|
'type' => QrCode::TYPE_EVENT,
|
||||||
|
'label' => 'Summit',
|
||||||
|
'payload' => [
|
||||||
|
'content' => [
|
||||||
|
'title' => 'Summit',
|
||||||
|
'format' => 'virtual',
|
||||||
|
'programme_qr_id' => $programme->id,
|
||||||
|
'virtual_sessions' => [],
|
||||||
|
],
|
||||||
|
'style' => [],
|
||||||
|
],
|
||||||
|
'is_active' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
Http::fake([
|
||||||
|
config('meet.url').'/rooms/existing-room-uuid' => Http::response([
|
||||||
|
'room' => ['uuid' => 'existing-room-uuid'],
|
||||||
|
'join_url' => 'https://meet.ladill.com/r/existing-room-uuid',
|
||||||
|
], 200),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->withToken('test-meet-key')
|
||||||
|
->postJson('/api/service/v1/events/'.$event->id.'/link-room', [
|
||||||
|
'owner_ref' => $this->owner->public_id,
|
||||||
|
'meet_room_uuid' => 'existing-room-uuid',
|
||||||
|
'meet_room_type' => 'town_hall',
|
||||||
|
'join_url' => 'https://meet.ladill.com/r/existing-room-uuid',
|
||||||
|
'title' => 'Opening keynote',
|
||||||
|
])
|
||||||
|
->assertOk()
|
||||||
|
->assertJsonPath('event.meet_room_uuid', 'existing-room-uuid');
|
||||||
|
|
||||||
|
Http::assertSent(function ($request) {
|
||||||
|
return $request->method() === 'PATCH'
|
||||||
|
&& str_ends_with($request->url(), '/rooms/existing-room-uuid')
|
||||||
|
&& ($request['settings']['programme_snapshot']['title'] ?? '') === 'Summit programme'
|
||||||
|
&& ($request['settings']['programme_snapshot']['days'][0]['items'][0]['title'] ?? '') === 'Opening keynote';
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user