From d8914b96fef3b9bd8233324ff6f58dcce33f56dd Mon Sep 17 00:00:00 2001 From: isaacclad Date: Sat, 4 Jul 2026 11:48:37 +0000 Subject: [PATCH] Skip Mail calendar sync for Meet rooms created by Ladill Events. Events owns calendar entries for events-sourced rooms so virtual sessions do not duplicate on the webmail calendar. Co-authored-by: Cursor --- app/Models/Room.php | 5 +++++ app/Services/Meet/CalendarService.php | 8 ++++++-- tests/Feature/MeetWebTest.php | 27 +++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/app/Models/Room.php b/app/Models/Room.php index 7532439..807e41b 100644 --- a/app/Models/Room.php +++ b/app/Models/Room.php @@ -200,6 +200,11 @@ class Room extends Model return \App\Support\EventsSourceLink::isLinked($this); } + public function isEventsSourced(): bool + { + return (($this->source ?? [])['app'] ?? '') === 'events'; + } + public function hasEventsRegistrationInvite(?string $email): bool { if ($email === null || trim($email) === '') { diff --git a/app/Services/Meet/CalendarService.php b/app/Services/Meet/CalendarService.php index 726840c..c730c71 100644 --- a/app/Services/Meet/CalendarService.php +++ b/app/Services/Meet/CalendarService.php @@ -20,7 +20,7 @@ class CalendarService public function syncRoomCreated(Room $room, User $host): void { - if (! $room->scheduled_at) { + if (! $room->scheduled_at || $room->isEventsSourced()) { return; } @@ -39,7 +39,7 @@ class CalendarService public function syncRoomUpdated(Room $room, User $host): void { - if (! $room->scheduled_at) { + if (! $room->scheduled_at || $room->isEventsSourced()) { return; } @@ -59,6 +59,10 @@ class CalendarService public function syncRoomCancelled(Room $room, User $host): void { + if ($room->isEventsSourced()) { + return; + } + if ($mailbox = $this->resolveMailMailbox($host)) { if ($room->calendar_event_id) { $this->mail->deleteEventForMailbox($mailbox, $room); diff --git a/tests/Feature/MeetWebTest.php b/tests/Feature/MeetWebTest.php index 22d66c4..ebdce84 100644 --- a/tests/Feature/MeetWebTest.php +++ b/tests/Feature/MeetWebTest.php @@ -769,6 +769,33 @@ class MeetWebTest extends TestCase }); } + public function test_events_sourced_room_does_not_sync_to_mail_calendar(): void + { + \Illuminate\Support\Facades\Http::fake([ + 'mail.ladill.com/*' => \Illuminate\Support\Facades\Http::response(['data' => ['id' => 99]], 201), + ]); + + config([ + 'meet.calendar.mail.api_url' => 'https://mail.ladill.com/api/service/v1', + 'meet.calendar.mail.api_key' => 'mail-test-key', + ]); + + $room = $this->createRoom([ + 'scheduled_at' => now()->addDay(), + 'source' => [ + 'app' => 'events', + 'entity_type' => 'virtual_session', + 'entity_id' => 'vs-1', + 'event_id' => '42', + ], + ]); + + app(\App\Services\Meet\CalendarService::class)->syncRoomCreated($room, $this->user); + + \Illuminate\Support\Facades\Http::assertNothingSent(); + $this->assertNull($room->fresh()->calendar_event_id); + } + public function test_host_can_create_conference(): void { $this->actingAs($this->user)