using System; using System.Collections.Generic; using LiteDB; namespace Vanadium.Classes.DBs.DBClasses { public static class HwidDBClasses { /// /// One machine, and every account that has ever reported from it. /// /// The ban fields live on the record rather than in a second collection so that a /// lookup by hwid answers both questions - who is this machine, and is it banned - /// in a single read, on the path that runs for every client that checks in. /// /// public class HwidRecord { [BsonId] public string Hwid { get; set; } public List PlayerIds { get; set; } = new(); public DateTime FirstSeen { get; set; } public DateTime LastSeen { get; set; } /// True while the machine itself is banned, separately from any account. public bool IsBanned { get; set; } /// Why. Required when banning; a blank reason makes a ban unreviewable. public string BanReason { get; set; } /// Player id of the moderator who issued it, or a system name. public string BannedBy { get; set; } public DateTime? BannedAt { get; set; } /// Null bans permanently. public DateTime? BanExpiresAt { get; set; } /// /// Accounts linked to the machine at the moment of the ban. A snapshot: it shows /// what the moderator was looking at, which is not always what the link table /// says later. /// public List LinkedAtBan { get; set; } = new(); public bool BanIsActive(DateTime utcNow) => IsBanned && (BanExpiresAt == null || BanExpiresAt > utcNow); } } }