Persist Events programme on the room when linking from Meet.
Deploy Ladill Meet / deploy (push) Successful in 46s
Deploy Ladill Meet / deploy (push) Successful in 46s
Store programme_snapshot from the link-room response locally and merge existing room settings on service API updates. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -214,7 +214,10 @@ class ServiceRoomController extends Controller
|
||||
|
||||
if (isset($validated['settings'])) {
|
||||
$type = $this->resolveType(array_merge(['type' => $room->type], $validated));
|
||||
$update['settings'] = $this->mergeSettingsForType($type, $validated['settings']);
|
||||
$update['settings'] = $this->mergeSettingsForType(
|
||||
$type,
|
||||
array_merge($room->settings ?? [], $validated['settings']),
|
||||
);
|
||||
}
|
||||
|
||||
$room = $this->rooms->update($room, $update, $host);
|
||||
|
||||
@@ -37,7 +37,7 @@ class EventsLinkService
|
||||
'virtual_session_id' => $virtualSessionId,
|
||||
]);
|
||||
|
||||
$room->update([
|
||||
$updates = [
|
||||
'source' => [
|
||||
'app' => 'events',
|
||||
'entity_type' => 'virtual_session',
|
||||
@@ -47,7 +47,17 @@ class EventsLinkService
|
||||
'registration_url' => (string) ($result['registration_url'] ?? ''),
|
||||
'short_code' => (string) ($result['short_code'] ?? ''),
|
||||
],
|
||||
]);
|
||||
];
|
||||
|
||||
$programme = $result['programme_snapshot'] ?? null;
|
||||
if (is_array($programme) && ! empty($programme['days'])) {
|
||||
$updates['settings'] = array_merge($room->settings ?? [], [
|
||||
'programme_snapshot' => $programme,
|
||||
'linked_programme_items' => (array) ($result['linked_programme_items'] ?? []),
|
||||
]);
|
||||
}
|
||||
|
||||
$room->update($updates);
|
||||
|
||||
return $room->fresh();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Member;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Room;
|
||||
use App\Models\User;
|
||||
use App\Services\Integrations\EventsLinkService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Tests\TestCase;
|
||||
|
||||
class EventsLinkServiceTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected User $user;
|
||||
|
||||
protected Organization $organization;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->user = User::create([
|
||||
'public_id' => 'test-user-events-link',
|
||||
'name' => 'Test User',
|
||||
'email' => 'events-link@example.com',
|
||||
]);
|
||||
|
||||
$this->organization = Organization::create([
|
||||
'owner_ref' => $this->user->public_id,
|
||||
'name' => 'Test Org',
|
||||
'slug' => 'test-org',
|
||||
'timezone' => 'UTC',
|
||||
'settings' => ['onboarded' => true],
|
||||
]);
|
||||
|
||||
Member::create([
|
||||
'owner_ref' => $this->user->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'user_ref' => $this->user->public_id,
|
||||
'role' => 'owner',
|
||||
]);
|
||||
|
||||
config([
|
||||
'meet.events_api_url' => 'https://events.test/api/service/v1',
|
||||
'meet.events_api_key' => 'test-events-key',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_link_stores_programme_snapshot_on_room_from_events_response(): void
|
||||
{
|
||||
Http::fake([
|
||||
'https://events.test/api/service/v1/events/42/link-room' => Http::response([
|
||||
'event' => [
|
||||
'id' => 42,
|
||||
'title' => 'Summit',
|
||||
'entity_id' => 'vs-abc',
|
||||
'registration_url' => 'https://events.test/e/summit',
|
||||
'short_code' => 'summit',
|
||||
'programme_snapshot' => [
|
||||
'title' => 'Summit programme',
|
||||
'days' => [
|
||||
[
|
||||
'label' => 'Day 1',
|
||||
'items' => [
|
||||
['time' => '09:00', 'title' => 'Opening keynote', 'host' => 'Alex'],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'linked_programme_items' => [
|
||||
['time' => '09:00', 'title' => 'Opening keynote', 'host' => 'Alex'],
|
||||
],
|
||||
],
|
||||
], 200),
|
||||
]);
|
||||
|
||||
$room = Room::create([
|
||||
'owner_ref' => $this->user->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'host_user_ref' => $this->user->public_id,
|
||||
'title' => 'Summit keynote',
|
||||
'type' => 'town_hall',
|
||||
'status' => 'scheduled',
|
||||
'scheduled_at' => now()->addDay(),
|
||||
'timezone' => 'UTC',
|
||||
'settings' => config('meet.default_settings'),
|
||||
]);
|
||||
|
||||
app(EventsLinkService::class)->link($room, $this->user, 42);
|
||||
|
||||
$room->refresh();
|
||||
|
||||
$this->assertSame('events', $room->source['app'] ?? null);
|
||||
$this->assertSame('Summit programme', $room->setting('programme_snapshot')['title'] ?? null);
|
||||
$this->assertSame('Opening keynote', $room->setting('linked_programme_items')[0]['title'] ?? null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user