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:
Artemy
2026-10-03 17:42:24 +07:00
parent 4603be9f71
commit 29cc51ee0c
127 changed files with 7290 additions and 2488 deletions
@@ -0,0 +1,32 @@
using System.ComponentModel.DataAnnotations;
using Govor.Domain.Models.Reactions;
namespace Govor.Contracts.Requests;
public class SetReactionRequest
{
public Guid ReactionId { get; set; }
}
public class CreateReactionPackRequest
{
[Required, MaxLength(100)] public string Name { get; set; } = string.Empty;
[MaxLength(500)] public string Description { get; set; } = string.Empty;
}
public class UpdateReactionPackRequest : CreateReactionPackRequest
{
public bool IsEnabled { get; set; } = true;
}
public class CreateEmojiReactionRequest
{
[Required, MaxLength(100)] public string Name { get; set; } = string.Empty;
[Required, MaxLength(64)] public string Emoji { get; set; } = string.Empty;
}
public class ChannelReactionPolicyRequest
{
[EnumDataType(typeof(ChannelReactionMode))] public ChannelReactionMode Mode { get; set; }
[MaxLength(100)] public List<Guid> ReactionIds { get; set; } = [];
}
@@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations;
using Govor.Domain.Models.Messages;
namespace Govor.Contracts.Requests;
public class ReadChatRequest
{
[EnumDataType(typeof(RecipientType))]
public RecipientType RecipientType { get; set; }
// Visible messages, or an inclusive boundary. Neither means the current chat snapshot.
[MaxLength(100)]
public List<Guid>? MessageIds { get; set; }
public Guid? UpToMessageId { get; set; }
}
@@ -0,0 +1,9 @@
using System.ComponentModel.DataAnnotations;
namespace Govor.Contracts.Requests;
public class SetPasswordRequest
{
[Required, MinLength(8), MaxLength(256)]
public string Password { get; set; } = string.Empty;
}
@@ -5,10 +5,9 @@ public class UserResponse
public Guid Id { get; set; }
public string Username { get; set; }
public string Description { get; set; }
public string PasswordHash { get; set; }
public DateTime WasOnline { get; set; }
public DateOnly CreatedOn { get; set; }
public Guid IconId {get; set;}
public Guid InviteId {get; set;}
public bool IsAdmin {get; set;}
}
}
@@ -5,6 +5,7 @@ public class MessageReactionResponse
public Guid Id { get; set; }
public Guid MessageId { get; set; }
public Guid UserId { get; set; }
public Guid? ReactionId { get; set; }
public string ReactionCode { get; set; } // "❤️", "🔥", "👍", ":custom_emoji:"
public DateTime ReactedAt { get; set; } = DateTime.UtcNow;
}
}
+2 -1
View File
@@ -13,8 +13,9 @@ public class MessageResponse
public bool IsEdited { get; set; } = false;
public DateTime? EditedAt { get; set; }
public Guid? ReplyToMessageId { get; set; }
public long ReactionsVersion { get; set; }
public List<MediaAttachmentResponse> MediaAttachments { get; set; } = new();
public List<MessageReactionResponse> Reactions { get; set; } = new();
public List<MessageViewResponse> MessageViews { get; set; } = new();
}
}
@@ -0,0 +1,35 @@
using Govor.Domain.Models.Reactions;
namespace Govor.Contracts.Responses;
public class ReactionPackResponse
{
public Guid Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string ShareCode { get; set; } = string.Empty;
public string SharePath => $"/api/reaction-packs/shared/{ShareCode}";
public bool IsDefault { get; set; }
public bool IsEnabled { get; set; }
public Guid? CreatedByUserId { get; set; }
public DateTime CreatedAt { get; set; }
public List<ReactionItemResponse> Reactions { get; set; } = [];
}
public class ReactionItemResponse
{
public Guid Id { get; set; }
public Guid PackId { get; set; }
public string Code { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public ReactionKind Kind { get; set; }
public string? Emoji { get; set; }
public Guid? MediaFileId { get; set; }
public string? MediaUrl => MediaFileId.HasValue ? $"/api/media/download/{MediaFileId}" : null;
public int Width { get; set; }
public int Height { get; set; }
public int SizeBytes { get; set; }
public int DurationMilliseconds { get; set; }
public bool IsEnabled { get; set; }
public DateTime CreatedAt { get; set; }
}
@@ -0,0 +1,16 @@
using Govor.Domain.Models.Messages;
namespace Govor.Contracts.Responses.SignalR;
public class ChatReadResponse
{
public Guid ChatId { get; set; }
public RecipientType RecipientType { get; set; }
public Guid ReaderId { get; set; }
public DateTime ReadAt { get; set; }
public Guid? UpToMessageId { get; set; }
public DateTime? UpToSentAt { get; set; }
public IReadOnlyList<Guid>? MessageIds { get; set; }
public int ReadCount { get; set; }
public int UnreadCount { get; set; }
}
@@ -49,6 +49,12 @@ public class HubResult<T>
ErrorMessage = message,
};
public static HubResult<T> Forbidden(string message) => new()
{
Status = HubResultStatus.Forbidden,
ErrorMessage = message
};
public static HubResult<T> UnprocessableEntity(string message) => new()
{
Status = HubResultStatus.UnprocessableEntity,
@@ -69,8 +75,9 @@ public enum HubResultStatus : int
NoContent = 204,
BadRequest = 400,
Unauthorized = 401,
Forbidden = 403,
NotFound = 404,
Conflict = 409,
UnprocessableEntity = 422,
ServerError = 500,
}
}
@@ -0,0 +1,30 @@
using Govor.Domain.Models.Messages;
using Govor.Domain.Models.Reactions;
namespace Govor.Contracts.Responses.SignalR;
public class ReactionCountResponse
{
public Guid? ReactionId { get; set; }
public string ReactionCode { get; set; } = string.Empty;
public int Count { get; set; }
}
public class MessageReactionsChangedResponse
{
public Guid MessageId { get; set; }
public Guid RecipientId { get; set; }
public RecipientType RecipientType { get; set; }
public long Version { get; set; }
public Guid ActorId { get; set; }
public MessageReactionResponse? ActorReaction { get; set; }
public List<ReactionCountResponse> Counts { get; set; } = [];
}
public class ChannelReactionPolicyResponse
{
public Guid GroupId { get; set; }
public ChannelReactionMode Mode { get; set; }
public long Version { get; set; }
public List<Guid> ReactionIds { get; set; } = [];
}