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>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Events\ServiceEventOccurred;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Events\ServiceEventSignature;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class ServiceEventController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
$secret = (string) config('service_events.inbound_secret');
|
||||
$signature = (string) $request->header('X-Ladill-Signature', '');
|
||||
|
||||
if (! ServiceEventSignature::verify($request->getContent(), $signature, $secret)) {
|
||||
return response()->json(['error' => 'invalid signature'], 401);
|
||||
}
|
||||
|
||||
$eventId = (string) $request->header('X-Ladill-Event-Id', (string) $request->input('id', ''));
|
||||
if ($eventId !== '') {
|
||||
if (Cache::has("svcevt:{$eventId}")) {
|
||||
return response()->json(['status' => 'duplicate']);
|
||||
}
|
||||
Cache::put("svcevt:{$eventId}", true, now()->addDay());
|
||||
}
|
||||
|
||||
event(new ServiceEventOccurred((string) $request->input('event'), (array) $request->input('data', [])));
|
||||
|
||||
return response()->json(['status' => 'accepted']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Meet\Concerns\ScopesToAccount;
|
||||
use App\Models\Room;
|
||||
use App\Services\Meet\RoomService;
|
||||
use App\Services\Meet\SessionService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RoomController extends Controller
|
||||
{
|
||||
use ScopesToAccount;
|
||||
|
||||
public function __construct(
|
||||
protected RoomService $rooms,
|
||||
protected SessionService $sessions,
|
||||
) {}
|
||||
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$this->authorizeAbility($request, 'meetings.view');
|
||||
$organization = $this->organization($request);
|
||||
$owner = $this->ownerRef($request);
|
||||
|
||||
$query = Room::owned($owner)->where('organization_id', $organization->id);
|
||||
$this->scopeToBranch($request, $query);
|
||||
|
||||
$rooms = $query->orderByDesc('scheduled_at')->paginate(20);
|
||||
|
||||
return response()->json($rooms);
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$this->authorizeAbility($request, 'meetings.create');
|
||||
$organization = $this->organization($request);
|
||||
|
||||
$validated = $request->validate([
|
||||
'title' => ['required', 'string', 'max:255'],
|
||||
'description' => ['nullable', 'string'],
|
||||
'scheduled_at' => ['nullable', 'date'],
|
||||
'passcode' => ['nullable', 'string', 'max:20'],
|
||||
'settings' => ['nullable', 'array'],
|
||||
'source' => ['nullable', 'array'],
|
||||
]);
|
||||
|
||||
$room = empty($validated['scheduled_at'])
|
||||
? $this->rooms->createInstant($request->user(), $organization, $validated)
|
||||
: $this->rooms->createScheduled($request->user(), $organization, $validated);
|
||||
|
||||
return response()->json([
|
||||
'room' => $room,
|
||||
'join_url' => $room->joinUrl(),
|
||||
], 201);
|
||||
}
|
||||
|
||||
public function show(Request $request, Room $room): JsonResponse
|
||||
{
|
||||
$this->authorizeAbility($request, 'meetings.view');
|
||||
$this->authorizeOwner($request, $room);
|
||||
|
||||
return response()->json([
|
||||
'room' => $room->load('sessions'),
|
||||
'join_url' => $room->joinUrl(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function start(Request $request, Room $room): JsonResponse
|
||||
{
|
||||
$this->authorizeAbility($request, 'meetings.host');
|
||||
$this->authorizeOwner($request, $room);
|
||||
|
||||
$session = $this->sessions->start($room, $request->user());
|
||||
|
||||
return response()->json([
|
||||
'session' => $session,
|
||||
'room_url' => route('meet.room', $session),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?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' => ['required', '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 = Organization::findOrFail($validated['organization_id']);
|
||||
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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user