using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace RegexBot.Data; /// /// Represents an item in the guild message cache. /// [Table("cache_guildmessages")] public class CachedGuildMessage { /// /// Gets the message's snowflake ID. /// [Key] [DatabaseGenerated(DatabaseGeneratedOption.None)] public long MessageId { get; set; } /// /// Gets the message author's snowflake ID. /// public long AuthorId { get; set; } /// /// Gets the associated guild's snowflake ID. /// public long GuildId { get; set; } /// /// Gets the corresponding channel's snowflake ID. /// public long ChannelId { get; set; } /// /// Gets the timestamp showing when this message was originally created. /// /// /// Though it's possible to draw this from , it is stored in the database /// as a separate field for any possible necessary use via database queries. /// public DateTimeOffset CreatedAt { get; set; } /// /// Gets the timestamp, if any, showing when this message was last edited. /// public DateTimeOffset? EditedAt { get; set; } /// /// Gets a list of file names thata were attached to this message. /// public List AttachmentNames { get; set; } = null!; /// /// Gets this message's content. /// public string Content { get; set; } = null!; /// /// If included in the query, references the associated for this entry. /// [ForeignKey(nameof(AuthorId))] [InverseProperty(nameof(CachedUser.GuildMessages))] public CachedUser Author { get; set; } = null!; // Used by MessageCachingSubservice internal static CachedGuildMessage? Clone(CachedGuildMessage? original) { if (original == null) return null; return new() { MessageId = original.MessageId, AuthorId = original.AuthorId, GuildId = original.GuildId, ChannelId = original.ChannelId, CreatedAt = original.CreatedAt, EditedAt = original.EditedAt, AttachmentNames = new(original.AttachmentNames), Content = original.Content }; } }