From 4cc4970916119e0ebcb98c7e0b36816cbed38202 Mon Sep 17 00:00:00 2001 From: isaacclad Date: Wed, 1 Jul 2026 10:15:11 +0000 Subject: [PATCH] Show Ladill profile avatars in the meeting participants UI. Resolve participant photos from linked user records for the header host chip and participants panel, with initials as fallback. Co-authored-by: Cursor --- .../Meet/MeetingRoomController.php | 15 ++--- app/Services/Meet/ParticipantPresenter.php | 64 +++++++++++++++++++ resources/views/meet/room/show.blade.php | 43 ++++++++----- 3 files changed, 96 insertions(+), 26 deletions(-) create mode 100644 app/Services/Meet/ParticipantPresenter.php diff --git a/app/Http/Controllers/Meet/MeetingRoomController.php b/app/Http/Controllers/Meet/MeetingRoomController.php index bec7ee8..019491b 100644 --- a/app/Http/Controllers/Meet/MeetingRoomController.php +++ b/app/Http/Controllers/Meet/MeetingRoomController.php @@ -7,6 +7,7 @@ use App\Models\Participant; use App\Models\Session; use App\Services\Meet\ChatService; use App\Services\Meet\Media\MediaProviderInterface; +use App\Services\Meet\ParticipantPresenter; use App\Services\Meet\RecordingService; use App\Services\Meet\SecurityPolicyService; use App\Services\Meet\SessionService; @@ -146,6 +147,8 @@ class MeetingRoomController extends Controller $session->load(['participants' => fn ($q) => $q->where('status', 'joined')]); + $avatars = ParticipantPresenter::avatarMap($session->participants, $session->room->host_user_ref); + $messages = $this->chat->recentMessages($session, 50); $reactions = $session->reactions()->where('created_at', '>=', now()->subMinutes(5))->latest()->limit(20)->get(); $qa = app(\App\Services\Meet\QaService::class)->forSession($session, true); @@ -161,15 +164,9 @@ class MeetingRoomController extends Controller ->get(); return response()->json([ - 'participants' => $session->participants->map(fn ($p) => [ - 'uuid' => $p->uuid, - 'display_name' => $p->display_name, - 'role' => $p->role, - 'hand_raised' => $p->hand_raised, - 'is_muted' => $p->is_muted, - 'is_video_off' => $p->is_video_off, - 'breakout_room_id' => $p->breakout_room_id, - ]), + 'participants' => $session->participants->map( + fn ($p) => ParticipantPresenter::toArray($p, $avatars, $session->room->host_user_ref) + ), 'messages' => $messages->map(fn ($m) => [ 'uuid' => $m->uuid, 'sender_name' => $m->sender_name, diff --git a/app/Services/Meet/ParticipantPresenter.php b/app/Services/Meet/ParticipantPresenter.php new file mode 100644 index 0000000..a83c678 --- /dev/null +++ b/app/Services/Meet/ParticipantPresenter.php @@ -0,0 +1,64 @@ + $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 + */ + public static function toArray(Participant $participant, Collection $avatars, ?string $roomHostUserRef = null): array + { + return [ + 'uuid' => $participant->uuid, + 'display_name' => $participant->display_name, + 'role' => $participant->role, + '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; + } +} diff --git a/resources/views/meet/room/show.blade.php b/resources/views/meet/room/show.blade.php index 6069c35..e9f1283 100644 --- a/resources/views/meet/room/show.blade.php +++ b/resources/views/meet/room/show.blade.php @@ -10,16 +10,12 @@ @php - $joinedParticipants = $session->participants - ->where('status', 'joined') - ->map(fn ($p) => [ - 'uuid' => $p->uuid, - 'display_name' => $p->display_name, - 'role' => $p->role, - 'hand_raised' => $p->hand_raised, - 'is_muted' => $p->is_muted, - 'is_video_off' => $p->is_video_off, - ]) + use App\Services\Meet\ParticipantPresenter; + + $joined = $session->participants->where('status', 'joined'); + $participantAvatars = ParticipantPresenter::avatarMap($joined, $room->host_user_ref); + $joinedParticipants = $joined + ->map(fn ($p) => ParticipantPresenter::toArray($p, $participantAvatars, $room->host_user_ref)) ->values(); @endphp
- + + + +
@@ -375,9 +377,16 @@