using MediatR;

namespace ChatService.API.Application.Queries.Conversations;

/// <summary>
/// EN: Query to get user's conversations.
/// VI: Query để lấy các cuộc hội thoại của user.
/// </summary>
public record GetConversationsQuery(
    Guid UserId,
    int Page = 1,
    int PageSize = 20
) : IRequest<GetConversationsResult>;

public record GetConversationsResult(
    IEnumerable<ConversationDto> Conversations,
    int TotalCount,
    int Page,
    int PageSize
);

public record ConversationDto(
    Guid Id,
    string Type,
    string? Name,
    string? AvatarUrl,
    IEnumerable<ConversationParticipantDto> Participants,
    LastMessageDto? LastMessage,
    int UnreadCount,
    DateTime CreatedAt,
    DateTime UpdatedAt
);

public record ConversationParticipantDto(
    Guid ChatUserId,
    string DisplayName,
    string? AvatarUrl,
    string Role,
    DateTime? LastReadAt
);

public record LastMessageDto(
    Guid MessageId,
    Guid SenderId,
    string SenderName,
    string Type,
    DateTime CreatedAt
);
