Fix Ladill Mail calendar sync mailbox resolution and updates.
Deploy Ladill Meet / deploy (push) Successful in 1m10s

Use the connected mail calendar mailbox when set, skip API calls when
MAIL_API_KEY_MEET is unset, and call syncRoomUpdated on room edits.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-04 10:59:59 +00:00
co-authored by Cursor
parent 7a0beaa721
commit 25de2ed7bc
4 changed files with 64 additions and 7 deletions
@@ -22,6 +22,10 @@ class MailCalendarProvider
public function createEventForMailbox(string $mailbox, Room $room): ?string
{
if (! filled(config('meet.calendar.mail.api_key'))) {
return null;
}
$response = Http::withToken((string) config('meet.calendar.mail.api_key'))
->acceptJson()
->timeout(10)
+30 -6
View File
@@ -24,8 +24,8 @@ class CalendarService
return;
}
if ($host->email) {
$eventId = $this->mail->createEventForMailbox($host->email, $room);
if ($mailbox = $this->resolveMailMailbox($host)) {
$eventId = $this->mail->createEventForMailbox($mailbox, $room);
if ($eventId) {
$room->update(['calendar_event_id' => $eventId]);
}
@@ -43,9 +43,9 @@ class CalendarService
return;
}
if ($host->email) {
if ($mailbox = $this->resolveMailMailbox($host)) {
if ($room->calendar_event_id) {
$this->mail->updateEventForMailbox($host->email, $room);
$this->mail->updateEventForMailbox($mailbox, $room);
} else {
$this->syncRoomCreated($room, $host);
}
@@ -59,8 +59,10 @@ class CalendarService
public function syncRoomCancelled(Room $room, User $host): void
{
if ($host->email && $room->calendar_event_id) {
$this->mail->deleteEventForMailbox($host->email, $room);
if ($mailbox = $this->resolveMailMailbox($host)) {
if ($room->calendar_event_id) {
$this->mail->deleteEventForMailbox($mailbox, $room);
}
}
$connection = $this->connectionFor($host);
@@ -71,6 +73,28 @@ class CalendarService
$room->update(['calendar_event_id' => null]);
}
public function mailCalendarConfigured(): bool
{
return filled(config('meet.calendar.mail.api_key'))
&& filled(config('meet.calendar.mail.api_url'));
}
protected function resolveMailMailbox(User $host): ?string
{
if (! $this->mailCalendarConfigured()) {
return null;
}
$connection = $this->connectionFor($host, 'mail');
if ($connection?->calendar_id) {
return strtolower(trim((string) $connection->calendar_id));
}
$email = strtolower(trim((string) $host->email));
return filter_var($email, FILTER_VALIDATE_EMAIL) ? $email : null;
}
public function connectionFor(User $user, ?string $provider = null): ?CalendarConnection
{
$query = CalendarConnection::where('user_ref', $user->ownerRef());
+1 -1
View File
@@ -94,7 +94,7 @@ class RoomService
AuditLogger::record($room->owner_ref, 'room.updated', $room->organization_id, $room->host_user_ref, Room::class, $room->id);
if ($host && $room->scheduled_at) {
app(CalendarService::class)->syncRoomCreated($room->fresh(), $host);
app(CalendarService::class)->syncRoomUpdated($room->fresh(), $host);
}
return $room->fresh();