using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
using NpgsqlTypes;
namespace Iceshrimp.Backend.Core.Database.Tables;
[Table("note")]
[Index("Uri", IsUnique = true)]
[Index("ReplyId")]
[Index("AttachedFileTypes")]
[Index("FileIds")]
[Index("RenoteId")]
[Index("Mentions")]
[Index("UserId")]
[Index("UserHost")]
[Index("VisibleUserIds")]
[Index("Tags")]
[Index("ThreadId")]
[Index("CreatedAt")]
[Index("ChannelId")]
[Index("CreatedAt", "UserId")]
[Index("Id", "UserHost")]
[Index("Url")]
[Index("UserId", "Id")]
public class Note {
[Key]
[Column("id")]
[StringLength(32)]
public string Id { get; set; } = null!;
///
/// The created date of the Note.
///
[Column("createdAt")]
public DateTime CreatedAt { get; set; }
///
/// The ID of reply target.
///
[Column("replyId")]
[StringLength(32)]
public string? ReplyId { get; set; }
///
/// The ID of renote target.
///
[Column("renoteId")]
[StringLength(32)]
public string? RenoteId { get; set; }
[Column("text")] public string? Text { get; set; }
[Column("name")] [StringLength(256)] public string? Name { get; set; }
[Column("cw")] [StringLength(512)] public string? Cw { get; set; }
///
/// The ID of author.
///
[Column("userId")]
[StringLength(32)]
public string UserId { get; set; } = null!;
[Column("visibility")] public NoteVisibility Visibility { get; set; }
[Column("localOnly")] public bool LocalOnly { get; set; }
[Column("renoteCount")] public short RenoteCount { get; set; }
[Column("repliesCount")] public short RepliesCount { get; set; }
[Column("reactions", TypeName = "jsonb")]
public string Reactions { get; set; } = null!;
///
/// The URI of a note. it will be null when the note is local.
///
[Column("uri")]
[StringLength(512)]
public string? Uri { get; set; }
[Column("score")] public int Score { get; set; }
[Column("fileIds", TypeName = "character varying(32)[]")]
public List FileIds { get; set; } = null!;
[Column("attachedFileTypes", TypeName = "character varying(256)[]")]
public List AttachedFileTypes { get; set; } = null!;
[Column("visibleUserIds", TypeName = "character varying(32)[]")]
public List VisibleUserIds { get; set; } = null!;
[Column("mentions", TypeName = "character varying(32)[]")]
public List Mentions { get; set; } = null!;
[Column("mentionedRemoteUsers")] public string MentionedRemoteUsers { get; set; } = null!;
[Column("emojis", TypeName = "character varying(128)[]")]
public List Emojis { get; set; } = null!;
[Column("tags", TypeName = "character varying(128)[]")]
public List Tags { get; set; } = null!;
[Column("hasPoll")] public bool HasPoll { get; set; }
///
/// [Denormalized]
///
[Column("userHost")]
[StringLength(512)]
public string? UserHost { get; set; }
///
/// [Denormalized]
///
[Column("replyUserId")]
[StringLength(32)]
public string? ReplyUserId { get; set; }
///
/// [Denormalized]
///
[Column("replyUserHost")]
[StringLength(512)]
public string? ReplyUserHost { get; set; }
///
/// [Denormalized]
///
[Column("renoteUserId")]
[StringLength(32)]
public string? RenoteUserId { get; set; }
///
/// [Denormalized]
///
[Column("renoteUserHost")]
[StringLength(512)]
public string? RenoteUserHost { get; set; }
///
/// The human readable url of a note. it will be null when the note is local.
///
[Column("url")]
[StringLength(512)]
public string? Url { get; set; }
///
/// The ID of source channel.
///
[Column("channelId")]
[StringLength(32)]
public string? ChannelId { get; set; }
[Column("threadId")]
[StringLength(256)]
public string? ThreadId { get; set; }
///
/// The updated date of the Note.
///
[Column("updatedAt")]
public DateTime? UpdatedAt { get; set; }
[ForeignKey("ChannelId")]
[InverseProperty("Notes")]
public virtual Channel? Channel { get; set; }
[InverseProperty("Note")]
public virtual ICollection ChannelNotePins { get; set; } = new List();
[InverseProperty("Note")] public virtual ICollection ClipNotes { get; set; } = new List();
[InverseProperty("Note")] public virtual HtmlNoteCacheEntry? HtmlNoteCacheEntry { get; set; }
[InverseProperty("Renote")] public virtual ICollection InverseRenote { get; set; } = new List();
[InverseProperty("Reply")] public virtual ICollection InverseReply { get; set; } = new List();
[InverseProperty("Note")] public virtual ICollection NoteEdits { get; set; } = new List();
[InverseProperty("Note")]
public virtual ICollection NoteFavorites { get; set; } = new List();
[InverseProperty("Note")]
public virtual ICollection NoteReactions { get; set; } = new List();
[InverseProperty("Note")] public virtual ICollection NoteUnreads { get; set; } = new List();
[InverseProperty("Note")]
public virtual ICollection NoteWatchings { get; set; } = new List();
[InverseProperty("Note")]
public virtual ICollection Notifications { get; set; } = new List();
[InverseProperty("Note")] public virtual Poll? Poll { get; set; }
[InverseProperty("Note")] public virtual ICollection PollVotes { get; set; } = new List();
[InverseProperty("Note")] public virtual PromoNote? PromoNote { get; set; }
[InverseProperty("Note")] public virtual ICollection PromoReads { get; set; } = new List();
[ForeignKey("RenoteId")]
[InverseProperty("InverseRenote")]
public virtual Note? Renote { get; set; }
[ForeignKey("ReplyId")]
[InverseProperty("InverseReply")]
public virtual Note? Reply { get; set; }
[ForeignKey("UserId")]
[InverseProperty("Notes")]
public virtual User User { get; set; } = null!;
[InverseProperty("Note")]
public virtual ICollection UserNotePins { get; set; } = new List();
[PgName("note_visibility_enum")]
public enum NoteVisibility {
[PgName("public")] Public,
[PgName("home")] Home,
[PgName("followers")] Followers,
[PgName("specified")] Specified,
[PgName("hidden")] Hidden
}
}