Files
ladill-meet/app/Services/Meet/ConferenceService.php
T
isaaccladandCursor 799c302e2a
Deploy Ladill Meet / deploy (push) Successful in 50s
Improve conferences, guest entry, Afia, and cross-app scheduling.
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>
2026-07-01 20:12:57 +00:00

88 lines
2.3 KiB
PHP

<?php
namespace App\Services\Meet;
use App\Models\Invitation;
use App\Models\Participant;
use App\Models\Room;
use App\Models\Session;
use App\Models\User;
class ConferenceService
{
/**
* @return list<string>
*/
public function presenterRefs(Room $room): array
{
return array_values(array_unique(array_filter(
(array) $room->setting('presenter_refs', []),
)));
}
public function resolveJoinRole(Room $room, ?User $user, ?string $email, string $fallbackRole = 'guest'): string
{
if ($user && $user->ownerRef() === $room->host_user_ref) {
return 'host';
}
$presenterRefs = $this->presenterRefs($room);
if ($user && in_array($user->ownerRef(), $presenterRefs, true)) {
return 'panelist';
}
if ($email && $this->invitationRole($room, $email) === 'panelist') {
return 'panelist';
}
if ($room->isTownHall()) {
return 'attendee';
}
return $fallbackRole;
}
public function canJoinSession(Room $room, Session $session, string $role): bool
{
if ($session->session_mode !== 'green_room') {
return true;
}
return in_array($role, ['host', 'co_host', 'panelist'], true);
}
public function isPresenter(Session $session, Participant $participant): bool
{
if (in_array($participant->role, ['host', 'co_host', 'panelist'], true)) {
return true;
}
$refs = (array) $session->presenter_refs;
return $participant->user_ref && in_array($participant->user_ref, $refs, true);
}
public function canPublish(Room $room, Participant $participant): bool
{
return in_array($participant->role, ['host', 'co_host', 'panelist'], true);
}
public function registerPresenter(Session $session, ?User $user, string $role): void
{
if (! $user || ! in_array($role, ['host', 'co_host', 'panelist'], true)) {
return;
}
app(TownHallService::class)->addPresenter($session, $user->ownerRef());
}
protected function invitationRole(Room $room, string $email): ?string
{
return Invitation::query()
->where('room_id', $room->id)
->where('email', strtolower(trim($email)))
->value('role');
}
}