Add null checks for participants and user
This commit is contained in:
parent
5a9606bf71
commit
707332b68e
1 changed files with 4 additions and 1 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue