Deploy Ladill Meet / deploy (push) Successful in 50s
Route guests through silent SSO to the Meet product page, fix Afia context query, add conference green-room UX and copy, and extend service API for Care/CRM/Invoice calendar integration. Co-authored-by: Cursor <cursoragent@cursor.com>
99 lines
3.6 KiB
PHP
99 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Organization;
|
|
use App\Models\Room;
|
|
use App\Models\User;
|
|
use App\Services\Integrations\WebhookDispatcher;
|
|
use App\Services\Meet\CalendarService;
|
|
use App\Services\Meet\InvitationService;
|
|
use App\Services\Meet\RoomService;
|
|
use App\Services\Meet\SessionService;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ServiceRoomController extends Controller
|
|
{
|
|
public function __construct(
|
|
protected RoomService $rooms,
|
|
protected SessionService $sessions,
|
|
protected InvitationService $invitations,
|
|
protected CalendarService $calendar,
|
|
protected WebhookDispatcher $webhooks,
|
|
) {}
|
|
|
|
public function store(Request $request): JsonResponse
|
|
{
|
|
$validated = $request->validate([
|
|
'owner_ref' => ['required', 'string'],
|
|
'organization_id' => ['nullable', 'integer', 'exists:meet_organizations,id'],
|
|
'host_user_ref' => ['required', 'string'],
|
|
'title' => ['required', 'string', 'max:255'],
|
|
'description' => ['nullable', 'string'],
|
|
'scheduled_at' => ['nullable', 'date'],
|
|
'duration_minutes' => ['nullable', 'integer', 'min:15', 'max:480'],
|
|
'passcode' => ['nullable', 'string', 'max:20'],
|
|
'settings' => ['nullable', 'array'],
|
|
'source' => ['required', 'array'],
|
|
'source.app' => ['required', 'string'],
|
|
'source.entity_type' => ['nullable', 'string'],
|
|
'source.entity_id' => ['nullable', 'string'],
|
|
'invite_emails' => ['nullable', 'array'],
|
|
'invite_emails.*' => ['email'],
|
|
]);
|
|
|
|
$organization = isset($validated['organization_id'])
|
|
? Organization::findOrFail($validated['organization_id'])
|
|
: Organization::owned($validated['owner_ref'])->firstOrFail();
|
|
abort_unless($organization->owner_ref === $validated['owner_ref'], 403);
|
|
|
|
$host = User::where('public_id', $validated['host_user_ref'])->firstOrFail();
|
|
|
|
$room = empty($validated['scheduled_at'])
|
|
? $this->rooms->createInstant($host, $organization, $validated)
|
|
: $this->rooms->createScheduled($host, $organization, $validated);
|
|
|
|
if (! empty($validated['invite_emails'])) {
|
|
$invites = collect($validated['invite_emails'])->map(fn ($email) => ['email' => $email])->all();
|
|
$this->invitations->inviteToRoom($room, $invites, $host);
|
|
}
|
|
|
|
if ($room->scheduled_at) {
|
|
$this->calendar->syncRoomCreated($room, $host);
|
|
}
|
|
|
|
$this->webhooks->roomCreated($room);
|
|
|
|
return response()->json([
|
|
'room' => $room->fresh(),
|
|
'join_url' => $room->joinUrl(),
|
|
'embed_url' => route('meet.join', $room),
|
|
], 201);
|
|
}
|
|
|
|
public function show(Room $room): JsonResponse
|
|
{
|
|
return response()->json([
|
|
'room' => $room->load('sessions'),
|
|
'join_url' => $room->joinUrl(),
|
|
'embed_url' => route('meet.join', $room),
|
|
]);
|
|
}
|
|
|
|
public function start(Request $request, Room $room): JsonResponse
|
|
{
|
|
$host = User::where('public_id', $request->input('host_user_ref', $room->host_user_ref))->firstOrFail();
|
|
abort_unless($room->host_user_ref === $host->ownerRef(), 403);
|
|
|
|
$session = $this->sessions->start($room, $host);
|
|
|
|
return response()->json([
|
|
'session' => $session,
|
|
'room_url' => route('meet.room', $session),
|
|
'join_url' => $room->joinUrl(),
|
|
]);
|
|
}
|
|
}
|