using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Microsoft.EntityFrameworkCore; namespace Iceshrimp.Backend.Core.Database.Tables; [Table("drive_file")] [Index("IsLink")] [Index("Md5")] [Index("UserId", "FolderId", "Id")] [Index("UserId")] [Index("UserHost")] [Index("Type")] [Index("IsSensitive")] [Index("FolderId")] [Index("WebpublicAccessKey", IsUnique = true)] [Index("CreatedAt")] [Index("AccessKey", IsUnique = true)] [Index("Uri")] [Index("ThumbnailAccessKey", IsUnique = true)] public class DriveFile { [Key] [Column("id")] [StringLength(32)] public string Id { get; set; } = null!; /// /// The created date of the DriveFile. /// [Column("createdAt")] public DateTime CreatedAt { get; set; } /// /// The owner ID. /// [Column("userId")] [StringLength(32)] public string? UserId { get; set; } /// /// The host of owner. It will be null if the user in local. /// [Column("userHost")] [StringLength(512)] public string? UserHost { get; set; } /// /// The MD5 hash of the DriveFile. /// [Column("md5")] [StringLength(32)] public string Md5 { get; set; } = null!; /// /// The file name of the DriveFile. /// [Column("name")] [StringLength(256)] public string Name { get; set; } = null!; /// /// The content type (MIME) of the DriveFile. /// [Column("type")] [StringLength(128)] public string Type { get; set; } = null!; /// /// The file size (bytes) of the DriveFile. /// [Column("size")] public int Size { get; set; } /// /// The comment of the DriveFile. /// [Column("comment")] [StringLength(8192)] public string? Comment { get; set; } /// /// The any properties of the DriveFile. For example, it includes image width/height. /// [Column("properties", TypeName = "jsonb")] public string Properties { get; set; } = null!; [Column("storedInternal")] public bool StoredInternal { get; set; } /// /// The URL of the DriveFile. /// [Column("url")] [StringLength(512)] public string Url { get; set; } = null!; /// /// The URL of the thumbnail of the DriveFile. /// [Column("thumbnailUrl")] [StringLength(512)] public string? ThumbnailUrl { get; set; } /// /// The URL of the webpublic of the DriveFile. /// [Column("webpublicUrl")] [StringLength(512)] public string? WebpublicUrl { get; set; } [Column("accessKey")] [StringLength(256)] public string? AccessKey { get; set; } [Column("thumbnailAccessKey")] [StringLength(256)] public string? ThumbnailAccessKey { get; set; } [Column("webpublicAccessKey")] [StringLength(256)] public string? WebpublicAccessKey { get; set; } /// /// The URI of the DriveFile. it will be null when the DriveFile is local. /// [Column("uri")] [StringLength(512)] public string? Uri { get; set; } [Column("src")] [StringLength(512)] public string? Src { get; set; } /// /// The parent folder ID. If null, it means the DriveFile is located in root. /// [Column("folderId")] [StringLength(32)] public string? FolderId { get; set; } /// /// Whether the DriveFile is NSFW. /// [Column("isSensitive")] public bool IsSensitive { get; set; } /// /// Whether the DriveFile is direct link to remote server. /// [Column("isLink")] public bool IsLink { get; set; } /// /// The BlurHash string. /// [Column("blurhash")] [StringLength(128)] public string? Blurhash { get; set; } [Column("webpublicType")] [StringLength(128)] public string? WebpublicType { get; set; } [Column("requestHeaders", TypeName = "jsonb")] public string? RequestHeaders { get; set; } [Column("requestIp")] [StringLength(128)] public string? RequestIp { get; set; } [InverseProperty("Banner")] public virtual ICollection Channels { get; set; } = new List(); [ForeignKey("FolderId")] [InverseProperty("DriveFiles")] public virtual DriveFolder? Folder { get; set; } [InverseProperty("File")] public virtual ICollection MessagingMessages { get; set; } = new List(); [InverseProperty("EyeCatchingImage")] public virtual ICollection Pages { get; set; } = new List(); [ForeignKey("UserId")] [InverseProperty("DriveFiles")] public virtual User? User { get; set; } [InverseProperty("Avatar")] public virtual User? UserAvatar { get; set; } [InverseProperty("Banner")] public virtual User? UserBanner { get; set; } }