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,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Meet;
|
||||
|
||||
use App\Models\Participant;
|
||||
use App\Models\QaQuestion;
|
||||
use App\Models\Room;
|
||||
use App\Models\Session;
|
||||
use App\Models\User;
|
||||
use App\Models\WebinarRegistration;
|
||||
|
||||
class WebinarService
|
||||
{
|
||||
public function register(Room $room, string $email, string $displayName, array $metadata = []): WebinarRegistration
|
||||
{
|
||||
abort_unless($room->type === 'webinar', 422, 'Not a webinar room.');
|
||||
|
||||
$autoApprove = $room->setting('webinar_auto_approve', false);
|
||||
|
||||
return WebinarRegistration::updateOrCreate(
|
||||
['room_id' => $room->id, 'email' => $email],
|
||||
[
|
||||
'owner_ref' => $room->owner_ref,
|
||||
'display_name' => $displayName,
|
||||
'status' => $autoApprove ? 'approved' : 'pending',
|
||||
'approved_at' => $autoApprove ? now() : null,
|
||||
'metadata' => $metadata,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
public function approve(WebinarRegistration $registration, User $host): WebinarRegistration
|
||||
{
|
||||
$registration->update(['status' => 'approved', 'approved_at' => now()]);
|
||||
|
||||
return $registration->fresh();
|
||||
}
|
||||
|
||||
public function reject(WebinarRegistration $registration): WebinarRegistration
|
||||
{
|
||||
$registration->update(['status' => 'rejected']);
|
||||
|
||||
return $registration->fresh();
|
||||
}
|
||||
|
||||
public function findApprovedRegistration(Room $room, string $email): ?WebinarRegistration
|
||||
{
|
||||
return WebinarRegistration::where('room_id', $room->id)
|
||||
->where('email', $email)
|
||||
->where('status', 'approved')
|
||||
->first();
|
||||
}
|
||||
|
||||
public function findByAccessToken(string $token): ?WebinarRegistration
|
||||
{
|
||||
return WebinarRegistration::where('access_token', $token)->where('status', 'approved')->first();
|
||||
}
|
||||
|
||||
public function isWebinarAttendee(Room $room, Participant $participant): bool
|
||||
{
|
||||
return $room->type === 'webinar' && $participant->role === 'attendee';
|
||||
}
|
||||
|
||||
public function canPublish(Room $room, Participant $participant): bool
|
||||
{
|
||||
if ($room->type !== 'webinar') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return in_array($participant->role, ['host', 'co_host', 'panelist'], true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user