using SVSim.Database.Entities.Guild;
namespace SVSim.Database.Repositories.Guild;
public interface IGuildChatMessageRepository
{
/// Atomically allocate the next per-guild message_id and insert.
Task AppendAsync(GuildChatMessage msg, CancellationToken ct = default);
/// Window query. direction: 1=OLD (asc-walk older), 2=NEW (newer), 3=BOTH (around).
/// `start` may be 0 meaning "latest". Returns ordered oldest-to-newest.
Task> GetWindowAsync(int guildId, int start, int direction, int limit, CancellationToken ct = default);
Task GetMaxMessageIdAsync(int guildId, CancellationToken ct = default);
///
/// Returns the highest message_id for the guild, or null if no messages exist.
/// Adapts (which returns 0 when empty) for callers
/// that need null-vs-present semantics (e.g. GuildNotification.guild_room_message_id).
///
Task GetMaxMessageIdSafelyAsync(int guildId, CancellationToken ct = default);
Task DeleteAllForGuildAsync(int guildId, CancellationToken ct = default);
/// Fetch a single message by (guildId, messageId). Returns null if not found.
Task GetByMessageIdAsync(int guildId, int messageId, CancellationToken ct = default);
///
/// Fetch all DECK-type messages for a guild (non-null DeckPayload only — clears are excluded).
///
Task> GetDeckMessagesAsync(int guildId, CancellationToken ct = default);
///
/// For /guild_chat/delete_deck: clears the deck payload + body without removing the message row,
/// so the slot remains in the timeline ("[deleted]"). Returns false if not found / not deletable by caller.
/// bypasses the author check — pass true when caller is Leader or SubLeader.
///
Task ClearDeckAsync(int guildId, int messageId, long callerViewerId, bool leaderOverride, CancellationToken ct = default);
}