using Knot.Contracts.Messaging.Domain;

namespace Knot.Contracts.Messaging.Application.Abstractions;

public interface IMessageRepository
{
    void Add(Message message);
    Task<Message?> GetByIdAsync(Guid id, CancellationToken cancellationToken);
    Task<List<Message>> GetChatMessagesAsync(Guid chatId, int limit, int offset, CancellationToken cancellationToken);
    Task<Message?> GetLatestChatMessageAsync(Guid chatId, CancellationToken cancellationToken);
    Task<List<Message>> GetPinnedMessagesAsync(Guid chatId, CancellationToken cancellationToken);
    Task<List<Message>> SearchMessagesAsync(string query, Guid? chatId, Guid requestingUserId, CancellationToken cancellationToken);

    Task<List<Message>> GetChatMessagesCursorAsync(Guid chatId, DateTime? cursor, long? sequenceId, int limit, CancellationToken cancellationToken);
    Task<List<Message>> GetChatMessagesAroundAsync(Guid chatId, long sequenceId, int limit, CancellationToken cancellationToken);
    Task<List<Message>> GetChatMessagesAfterAsync(Guid chatId, long sequenceId, int limit, CancellationToken cancellationToken);
    Task<Message?> GetLastStoryMessageAsync(Guid chatId, Guid storyId, CancellationToken cancellationToken);

    Task UpdateAsync(Message message, CancellationToken cancellationToken);
    Task<List<Message>> GetAllMessagesAsync(CancellationToken cancellationToken);
    Task DeleteChatMessagesAsync(Guid chatId, CancellationToken cancellationToken);
    Task DeleteUserMessagesAsync(Guid userId, CancellationToken cancellationToken);
    Task RemoveAsync(Guid id, CancellationToken cancellationToken);
    Task DeleteAsync(Message message, CancellationToken cancellationToken);
}
