namespace OF_DL.Services;

public interface IDbService
{
    /// <summary>
    /// Inserts a message record when it does not already exist.
    /// </summary>
    Task AddMessage(string folder, long postId, string messageText, string price, bool isPaid, bool isArchived,
        DateTime createdAt, long userId);

    /// <summary>
    /// Inserts a post record when it does not already exist.
    /// </summary>
    Task AddPost(string folder, long postId, string messageText, string price, bool isPaid, bool isArchived,
        DateTime createdAt);

    /// <summary>
    /// Inserts a story record when it does not already exist.
    /// </summary>
    Task AddStory(string folder, long postId, string messageText, string price, bool isPaid, bool isArchived,
        DateTime createdAt);

    /// <summary>
    /// Creates or updates the per-user metadata database.
    /// </summary>
    Task CreateDb(string folder);

    /// <summary>
    /// Creates or updates the global users database.
    /// </summary>
    Task CreateUsersDb(Dictionary<string, long> users);

    /// <summary>
    /// Ensures a username matches the stored user ID and migrates folders if needed.
    /// </summary>
    Task CheckUsername(KeyValuePair<string, long> user, string path);

    /// <summary>
    /// Inserts a media record when it does not already exist.
    /// </summary>
    Task AddMedia(string folder, long mediaId, long postId, string link, string? directory, string? filename,
        long? size, string apiType, string mediaType, bool preview, bool downloaded, DateTime? createdAt);

    /// <summary>
    /// Updates the media record with local file details.
    /// </summary>
    Task UpdateMedia(string folder, long mediaId, string apiType, string directory, string filename, long size,
        bool downloaded, DateTime createdAt);

    /// <summary>
    /// Returns the stored size for a media record.
    /// </summary>
    Task<long> GetStoredFileSize(string folder, long mediaId, string apiType);

    /// <summary>
    /// Checks whether the media has been marked as downloaded.
    /// </summary>
    Task<bool> CheckDownloaded(string folder, long mediaId, string apiType);

    /// <summary>
    /// Returns the most recent post date based on downloaded and pending media.
    /// </summary>
    Task<DateTime?> GetMostRecentPostDate(string folder);
}
