mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
Add AutoMapper and message response models
Introduced AutoMapper to the API project and registered it in the DI container. Added mapping profiles for core models to DTOs and response objects. Refactored controllers to use AutoMapper for mapping entities to response DTOs. Implemented new response models for messages, media attachments, reactions, and views. Updated MessagesLoader to load messages with related data. Added a migration to support ChatGroupId in messages. Updated dependencies and fixed minor issues in related files.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
namespace Govor.Contracts.Responses;
|
||||
|
||||
public class MediaAttachmentResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid MessageId { get; set; }
|
||||
public Guid MediaFileId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Govor.Contracts.Responses;
|
||||
|
||||
public class MessageReactionResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid MessageId { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public string ReactionCode { get; set; } // "❤️", "🔥", "👍", ":custom_emoji:"
|
||||
public DateTime ReactedAt { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Govor.Core.Models.Messages;
|
||||
|
||||
namespace Govor.Contracts.Responses;
|
||||
|
||||
public class MessageResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid SenderId { get; set; }
|
||||
public Guid RecipientId { get; set; } // or GroupId
|
||||
public RecipientType RecipientType { get; set; }
|
||||
public string EncryptedContent { get; set; } = string.Empty;
|
||||
public DateTime SentAt { get; set; }
|
||||
public bool IsEdited { get; set; } = false;
|
||||
public DateTime? EditedAt { get; set; }
|
||||
public Guid? ReplyToMessageId { 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,9 @@
|
||||
namespace Govor.Contracts.Responses;
|
||||
|
||||
public class MessageViewResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid MessageId { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public DateTime ViewedAt { get; set; }
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class HubResult<T>
|
||||
};
|
||||
}
|
||||
|
||||
public enum HubResultStatus
|
||||
public enum HubResultStatus : int
|
||||
{
|
||||
Success = 200,
|
||||
Created = 201,
|
||||
|
||||
Reference in New Issue
Block a user