From 707332b68ea0b804ff2df0b8909bb16dc3ec4745 Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Wed, 5 Nov 2025 23:42:36 -0600 Subject: [PATCH] Add null checks for participants and user --- LANCommander.Server.Services/ChatService.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/LANCommander.Server.Services/ChatService.cs b/LANCommander.Server.Services/ChatService.cs index d381b252..7b77b234 100644 --- a/LANCommander.Server.Services/ChatService.cs +++ b/LANCommander.Server.Services/ChatService.cs @@ -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(); 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();