namespace ChatService.Domain.Events;

using ChatService.Domain.AggregatesModel.ConversationAggregate;
using MediatR;

/// <summary>
/// EN: Domain event raised when a new conversation is created.
/// VI: Domain event được phát ra khi một conversation mới được tạo.
/// </summary>
public class ConversationCreatedDomainEvent : INotification
{
    public Conversation Conversation { get; }

    public ConversationCreatedDomainEvent(Conversation conversation)
    {
        Conversation = conversation;
    }
}

/// <summary>
/// EN: Domain event raised when a message is sent.
/// VI: Domain event được phát ra khi một tin nhắn được gửi.
/// </summary>
public class MessageSentDomainEvent : INotification
{
    public Message Message { get; }
    public Conversation Conversation { get; }

    public MessageSentDomainEvent(Message message, Conversation conversation)
    {
        Message = message;
        Conversation = conversation;
    }
}

/// <summary>
/// EN: Domain event raised when a message is delivered.
/// VI: Domain event được phát ra khi tin nhắn được gửi đến.
/// </summary>
public class MessageDeliveredDomainEvent : INotification
{
    public Guid MessageId { get; }
    public Guid ConversationId { get; }
    public Guid RecipientId { get; }
    public DateTime DeliveredAt { get; }

    public MessageDeliveredDomainEvent(Guid messageId, Guid conversationId, Guid recipientId)
    {
        MessageId = messageId;
        ConversationId = conversationId;
        RecipientId = recipientId;
        DeliveredAt = DateTime.UtcNow;
    }
}

/// <summary>
/// EN: Domain event raised when a message is read.
/// VI: Domain event được phát ra khi tin nhắn được đọc.
/// </summary>
public class MessageReadDomainEvent : INotification
{
    public Guid MessageId { get; }
    public Guid ConversationId { get; }
    public Guid ReaderId { get; }
    public DateTime ReadAt { get; }

    public MessageReadDomainEvent(Guid messageId, Guid conversationId, Guid readerId)
    {
        MessageId = messageId;
        ConversationId = conversationId;
        ReaderId = readerId;
        ReadAt = DateTime.UtcNow;
    }
}

/// <summary>
/// EN: Domain event raised when a user joins a conversation room.
/// VI: Domain event được phát ra khi user tham gia phòng hội thoại.
/// </summary>
public class UserJoinedRoomDomainEvent : INotification
{
    public Guid UserId { get; }
    public Guid ConversationId { get; }
    public string UserName { get; }
    public DateTime JoinedAt { get; }

    public UserJoinedRoomDomainEvent(Guid userId, Guid conversationId, string userName)
    {
        UserId = userId;
        ConversationId = conversationId;
        UserName = userName;
        JoinedAt = DateTime.UtcNow;
    }
}

/// <summary>
/// EN: Domain event raised when a user leaves a conversation room.
/// VI: Domain event được phát ra khi user rời phòng hội thoại.
/// </summary>
public class UserLeftRoomDomainEvent : INotification
{
    public Guid UserId { get; }
    public Guid ConversationId { get; }
    public DateTime LeftAt { get; }

    public UserLeftRoomDomainEvent(Guid userId, Guid conversationId)
    {
        UserId = userId;
        ConversationId = conversationId;
        LeftAt = DateTime.UtcNow;
    }
}

/// <summary>
/// EN: Domain event raised when a user is typing in a conversation.
/// VI: Domain event được phát ra khi user đang gõ tin nhắn.
/// </summary>
public class TypingDomainEvent : INotification
{
    public Guid UserId { get; }
    public Guid ConversationId { get; }
    public string UserName { get; }
    public bool IsTyping { get; }

    public TypingDomainEvent(Guid userId, Guid conversationId, string userName, bool isTyping)
    {
        UserId = userId;
        ConversationId = conversationId;
        UserName = userName;
        IsTyping = isTyping;
    }
}

