mirror of
https://github.com/Govor-team/Govor.git
synced 2026-11-18 13:24:59 +00:00
Add reactions, reliable push & session checks
Implements message reactions and reaction packs (domain models, services, admin HTTP API, media processing via ImageSharp and limits) and adds reliable push delivery (ChatPushNotification, ChatPushDispatcher, ChatPushWorker, improved ChatNotificationService). Enhances message reading (ReadChat API, unread counts, concurrency-safe receipts) and tightens session security (access-token session validation in JWT, hub filter, SessionAuthorization). Improves SignalR behavior (session groups, reaction/channel events, hub/error mappings). Adds EF migrations, many controller fixes (Forbid handling, password API), tests (Govor.Server.Tests), docs, CI and tooling updates (Dockerfile → .NET 10, GH Actions matrix for sqlite/postgres, Govor.Server.slnx, global.json), and small infra changes (AutoMapper bump, NullPushProvider, storage/token handling).
This commit is contained in:
@@ -26,12 +26,13 @@ public class MessagesLoader : IMessagesLoader
|
||||
if (privateChatId == Guid.Empty)
|
||||
return Result.Failure<List<Message>>(Error.Failure(nameof(ArgumentException),"PrivateChatId id cannot be empty."));
|
||||
|
||||
var chatExists = await _dbContext.PrivateChats.AnyAsync(c => c.Id == privateChatId);
|
||||
if (!chatExists)
|
||||
return new List<Message>(0);
|
||||
if (!await _dbContext.HasChatAccessAsync(currentUser, privateChatId, RecipientType.User))
|
||||
return Result.Failure<List<Message>>(Error.Forbidden("Chat.AccessDenied", "You are not a member of this chat."));
|
||||
|
||||
var query = _dbContext.Messages
|
||||
.AsNoTracking()
|
||||
.Include(m => m.MessageViews)
|
||||
.Include(m => m.Reactions)
|
||||
.Include(m => m.MediaAttachments)
|
||||
.ThenInclude(m => m.MediaFile)
|
||||
.Where(m => m.RecipientType == RecipientType.User && m.RecipientId == privateChatId);
|
||||
@@ -50,13 +51,15 @@ public class MessagesLoader : IMessagesLoader
|
||||
return Result.Failure<List<Message>>(Error.Failure(nameof(ArgumentException),"Chat id cannot be empty."));
|
||||
|
||||
var isMember = await _dbContext.GroupMemberships
|
||||
.AnyAsync(gm => gm.UserId == currentUser && gm.GroupId == chatId);
|
||||
.AnyAsync(gm => gm.UserId == currentUser && gm.GroupId == chatId && !gm.IsBanned);
|
||||
|
||||
if (!isMember)
|
||||
return new List<Message>(0);
|
||||
if (!isMember)
|
||||
return Result.Failure<List<Message>>(Error.Forbidden("Chat.AccessDenied", "You are not a member of this chat."));
|
||||
|
||||
var query = _dbContext.Messages
|
||||
.AsNoTracking()
|
||||
.Include(m => m.MessageViews)
|
||||
.Include(m => m.Reactions)
|
||||
.Include(m => m.MediaAttachments)
|
||||
.ThenInclude(m => m.MediaFile)
|
||||
.AsSplitQuery()
|
||||
@@ -75,8 +78,10 @@ public class MessagesLoader : IMessagesLoader
|
||||
{
|
||||
return await baseQuery
|
||||
.OrderByDescending(m => m.SentAt)
|
||||
.ThenByDescending(m => m.Id)
|
||||
.Take(before)
|
||||
.OrderBy(m => m.SentAt)
|
||||
.ThenBy(m => m.Id)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
@@ -85,14 +90,18 @@ public class MessagesLoader : IMessagesLoader
|
||||
return [];
|
||||
|
||||
var beforeMessages = await baseQuery
|
||||
.Where(m => m.SentAt < startMessage.SentAt)
|
||||
.Where(m => m.SentAt < startMessage.SentAt ||
|
||||
(m.SentAt == startMessage.SentAt && m.Id.CompareTo(startMessage.Id) < 0))
|
||||
.OrderByDescending(m => m.SentAt)
|
||||
.ThenByDescending(m => m.Id)
|
||||
.Take(before)
|
||||
.ToListAsync();
|
||||
|
||||
var afterMessages = await baseQuery
|
||||
.Where(m => m.SentAt > startMessage.SentAt)
|
||||
.Where(m => m.SentAt > startMessage.SentAt ||
|
||||
(m.SentAt == startMessage.SentAt && m.Id.CompareTo(startMessage.Id) > 0))
|
||||
.OrderBy(m => m.SentAt)
|
||||
.ThenBy(m => m.Id)
|
||||
.Take(after)
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user