Optimize caching on chat member

🐛 Trying to fix uploading file permission check
This commit is contained in:
2025-05-25 20:18:27 +08:00
parent cbe913e535
commit 33767a6d7f
6 changed files with 37 additions and 46 deletions

View File

@ -33,23 +33,7 @@ public class MessageTypingHandler(AppDatabase db, ChatRoomService crs, ICacheSer
return;
}
var cacheKey = string.Format(MessageReadHandler.ChatMemberCacheKey, currentUser.Id, request.ChatRoomId);
var sender = await cache.GetAsync<ChatMember?>(cacheKey);
if (sender is null)
{
sender = await db.ChatMembers
.Where(m => m.AccountId == currentUser.Id && m.ChatRoomId == request.ChatRoomId)
.FirstOrDefaultAsync();
if (sender != null)
{
var chatRoomGroup = ChatRoomService.ChatRoomGroupPrefix + request.ChatRoomId;
await cache.SetWithGroupsAsync(cacheKey, sender,
[chatRoomGroup],
TimeSpan.FromMinutes(5));
}
}
var sender = await crs.GetChannelMember(currentUser.Id, request.ChatRoomId);
if (sender is null)
{
await socket.SendAsync(