🐛 Fix update participant can't get account id

This commit is contained in:
LittleSheep 2025-05-27 02:01:30 +08:00
parent 7d5a804865
commit b913682866

View File

@ -125,7 +125,7 @@ public class LivekitRealtimeService : IRealtimeService
RoomAdmin = isAdmin, RoomAdmin = isAdmin,
Room = sessionId Room = sessionId
}) })
.WithAttributes(new Dictionary<string, string> { { "account_id", account.Id.ToString() } }) .WithMetadata(JsonSerializer.Serialize(new Dictionary<string, string> { { "account_id", account.Id.ToString() } }))
.WithTtl(TimeSpan.FromHours(1)); .WithTtl(TimeSpan.FromHours(1));
return token.ToJwt(); return token.ToJwt();
} }
@ -199,7 +199,7 @@ public class LivekitRealtimeService : IRealtimeService
// Get the current participants list // Get the current participants list
var participants = await _cache.GetAsync<List<ParticipantCacheItem>>(participantsKey) ?? var participants = await _cache.GetAsync<List<ParticipantCacheItem>>(participantsKey) ??
new List<ParticipantCacheItem>(); [];
// Check if the participant already exists // Check if the participant already exists
var existingIndex = participants.FindIndex(p => p.Identity == participant.Identity); var existingIndex = participants.FindIndex(p => p.Identity == participant.Identity);
@ -253,7 +253,7 @@ public class LivekitRealtimeService : IRealtimeService
public async Task<List<ParticipantCacheItem>> GetRoomParticipantsAsync(string roomName) public async Task<List<ParticipantCacheItem>> GetRoomParticipantsAsync(string roomName)
{ {
var participantsKey = _GetParticipantsKey(roomName); var participantsKey = _GetParticipantsKey(roomName);
return await _cache.GetAsync<List<ParticipantCacheItem>>(participantsKey) ?? new List<ParticipantCacheItem>(); return await _cache.GetAsync<List<ParticipantCacheItem>>(participantsKey) ?? [];
} }
// Class to represent a participant in the cache // Class to represent a participant in the cache