From 093055f9abfa9643411a377b89defb8d1d6011cb Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 27 May 2025 02:18:39 +0800 Subject: [PATCH] :bug: Fix update call participants missing profile --- .../Chat/Realtime/LivekitService.cs | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/DysonNetwork.Sphere/Chat/Realtime/LivekitService.cs b/DysonNetwork.Sphere/Chat/Realtime/LivekitService.cs index 0dc7f30..c1c0bfa 100644 --- a/DysonNetwork.Sphere/Chat/Realtime/LivekitService.cs +++ b/DysonNetwork.Sphere/Chat/Realtime/LivekitService.cs @@ -298,25 +298,28 @@ public class LivekitRealtimeService : IRealtimeService Guid? accountId = null; var metadata = new Dictionary(); - if (!string.IsNullOrEmpty(participant.Metadata)) + if (string.IsNullOrEmpty(participant.Metadata)) + return new ParticipantCacheItem + { + Identity = participant.Identity, + Name = participant.Name, + AccountId = accountId, + State = participant.State, + Metadata = metadata, + JoinedAt = DateTime.UtcNow + }; + try { - try - { - metadata = JsonSerializer.Deserialize>(participant.Metadata) ?? - new Dictionary(); + metadata = JsonSerializer.Deserialize>(participant.Metadata) ?? + new Dictionary(); - if (metadata.TryGetValue("account_id", out var accountIdStr)) - { - if (Guid.TryParse(accountIdStr, out var parsedId)) - { - accountId = parsedId; - } - } - } - catch (Exception ex) - { - _logger.LogError(ex, "Failed to parse participant metadata"); - } + if (metadata.TryGetValue("account_id", out var accountIdStr)) + if (Guid.TryParse(accountIdStr, out var parsedId)) + accountId = parsedId; + } + catch (Exception ex) + { + _logger.LogError(ex, "Failed to parse participant metadata"); } return new ParticipantCacheItem @@ -363,10 +366,12 @@ public class LivekitRealtimeService : IRealtimeService .ToList(); var memberProfiles = new Dictionary(); - if (accountIds.Any()) + if (accountIds.Count != 0) { memberProfiles = await _db.ChatMembers .Where(m => m.ChatRoomId == roomInfo.RoomId && accountIds.Contains(m.AccountId)) + .Include(m => m.Account) + .ThenInclude(m => m.Profile) .ToDictionaryAsync(m => m.AccountId, m => m); }