Deploy Ladill Meet / deploy (push) Failing after 7s
Phases 0–18: core meetings, webinar, breakouts, team chat, live streaming, town hall, billing, and Ladill Mail calendar wiring. Co-authored-by: Cursor <cursoragent@cursor.com>
115 lines
3.7 KiB
PHP
115 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Meet;
|
|
|
|
use App\Models\Organization;
|
|
use App\Models\Room;
|
|
use App\Models\User;
|
|
use App\Services\Meet\Media\MediaProviderInterface;
|
|
use Illuminate\Support\Str;
|
|
|
|
class RoomService
|
|
{
|
|
public function __construct(
|
|
protected MediaProviderInterface $media,
|
|
) {}
|
|
|
|
/**
|
|
* @param array<string, mixed> $data
|
|
*/
|
|
public function createInstant(User $user, Organization $organization, array $data = []): Room
|
|
{
|
|
return $this->create($user, $organization, array_merge($data, [
|
|
'type' => 'instant',
|
|
'status' => 'scheduled',
|
|
'title' => $data['title'] ?? 'Instant meeting',
|
|
]));
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $data
|
|
*/
|
|
public function createScheduled(User $user, Organization $organization, array $data): Room
|
|
{
|
|
return $this->create($user, $organization, array_merge($data, [
|
|
'type' => 'scheduled',
|
|
'status' => 'scheduled',
|
|
]));
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $data
|
|
*/
|
|
public function create(User $user, Organization $organization, array $data): Room
|
|
{
|
|
$ownerRef = $user->ownerRef();
|
|
$settings = array_merge(config('meet.default_settings'), $data['settings'] ?? []);
|
|
|
|
$room = Room::create([
|
|
'owner_ref' => $ownerRef,
|
|
'organization_id' => $organization->id,
|
|
'branch_id' => $data['branch_id'] ?? null,
|
|
'host_user_ref' => $ownerRef,
|
|
'title' => $data['title'],
|
|
'description' => $data['description'] ?? null,
|
|
'type' => $data['type'] ?? 'instant',
|
|
'status' => $data['status'] ?? 'scheduled',
|
|
'slug' => $data['slug'] ?? null,
|
|
'scheduled_at' => $data['scheduled_at'] ?? now(),
|
|
'duration_minutes' => $data['duration_minutes'] ?? 60,
|
|
'timezone' => $data['timezone'] ?? $organization->timezone,
|
|
'passcode' => isset($data['passcode']) ? (string) $data['passcode'] : null,
|
|
'settings' => $settings,
|
|
'source' => $data['source'] ?? null,
|
|
]);
|
|
|
|
AuditLogger::record($ownerRef, 'room.created', $organization->id, $ownerRef, Room::class, $room->id);
|
|
|
|
app(\App\Services\Integrations\WebhookDispatcher::class)->roomCreated($room);
|
|
|
|
return $room;
|
|
}
|
|
|
|
public function ensurePersonalRoom(User $user, Organization $organization): Room
|
|
{
|
|
$ownerRef = $user->ownerRef();
|
|
$slug = 'personal-'.Str::slug($organization->slug);
|
|
|
|
return Room::firstOrCreate(
|
|
[
|
|
'owner_ref' => $ownerRef,
|
|
'organization_id' => $organization->id,
|
|
'type' => 'personal',
|
|
'slug' => $slug,
|
|
],
|
|
[
|
|
'host_user_ref' => $ownerRef,
|
|
'title' => $user->name."'s meeting room",
|
|
'status' => 'scheduled',
|
|
'scheduled_at' => now(),
|
|
'timezone' => $organization->timezone,
|
|
'settings' => config('meet.default_settings'),
|
|
],
|
|
);
|
|
}
|
|
|
|
public function cancel(Room $room, string $actorRef, ?User $host = null): Room
|
|
{
|
|
$room->update(['status' => 'cancelled']);
|
|
AuditLogger::record($room->owner_ref, 'room.cancelled', $room->organization_id, $actorRef, Room::class, $room->id);
|
|
|
|
if ($host) {
|
|
app(CalendarService::class)->syncRoomCancelled($room, $host);
|
|
}
|
|
|
|
app(\App\Services\Integrations\WebhookDispatcher::class)->roomCancelled($room);
|
|
|
|
return $room;
|
|
}
|
|
|
|
public function mediaRoomName(Room $room, ?string $sessionUuid = null): string
|
|
{
|
|
return 'meet-'.$room->uuid.($sessionUuid ? '-'.$sessionUuid : '');
|
|
}
|
|
}
|