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>
67 lines
2.0 KiB
PHP
67 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Meet;
|
|
|
|
use App\Models\Participant;
|
|
use App\Models\User;
|
|
use Illuminate\Support\Collection;
|
|
|
|
class ParticipantPresenter
|
|
{
|
|
/**
|
|
* @param Collection<int, Participant> $participants
|
|
*/
|
|
public static function avatarMap(Collection $participants, ?string $roomHostUserRef = null): Collection
|
|
{
|
|
$refs = $participants->pluck('user_ref')->filter();
|
|
|
|
if ($roomHostUserRef) {
|
|
$refs = $refs->push($roomHostUserRef)->unique();
|
|
}
|
|
|
|
if ($refs->isEmpty()) {
|
|
return collect();
|
|
}
|
|
|
|
return User::query()
|
|
->whereIn('public_id', $refs->all())
|
|
->get()
|
|
->keyBy('public_id');
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public static function toArray(Participant $participant, Collection $avatars, ?string $roomHostUserRef = null): array
|
|
{
|
|
return [
|
|
'uuid' => $participant->uuid,
|
|
'user_ref' => $participant->user_ref,
|
|
'display_name' => $participant->display_name,
|
|
'role' => $participant->role,
|
|
'status' => $participant->status,
|
|
'hand_raised' => $participant->hand_raised,
|
|
'is_muted' => $participant->is_muted,
|
|
'is_video_off' => $participant->is_video_off,
|
|
'breakout_room_id' => $participant->breakout_room_id,
|
|
'avatar_url' => self::avatarUrl($participant, $avatars, $roomHostUserRef),
|
|
];
|
|
}
|
|
|
|
public static function avatarUrl(Participant $participant, Collection $avatars, ?string $roomHostUserRef = null): ?string
|
|
{
|
|
if ($participant->user_ref) {
|
|
$url = $avatars->get($participant->user_ref)?->avatarUrl();
|
|
if ($url) {
|
|
return $url;
|
|
}
|
|
}
|
|
|
|
if (in_array($participant->role, ['host', 'co_host'], true) && $roomHostUserRef) {
|
|
return $avatars->get($roomHostUserRef)?->avatarUrl();
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|