Add null checks for participants and user

This commit is contained in:
Pat Hartl 2025-11-05 23:42:36 -06:00
parent 5a9606bf71
commit 707332b68e

View file

@ -108,6 +108,9 @@ namespace LANCommander.Server.Services
var threads = await cache.GetOrSetAsync(cacheKey, async _ =>
{
var user = await userService.GetAsync(userId);
if (user == null)
return new List<ChatThread>();
var dbThreads = await chatThreadService.Query(q =>
{
@ -115,7 +118,7 @@ namespace LANCommander.Server.Services
.AsNoTracking()
.AsSplitQuery()
.Include(t => t.Participants)
.Where(t => t.Participants.Any(p => p.Id == user.Id));
.Where(t => t.Participants != null && t.Participants.Any(p => p.Id == user.Id));
}).GetAsync();
return dbThreads.OrderByDescending(t => t.CreatedOn).ToList();