using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Microsoft.EntityFrameworkCore; using NpgsqlTypes; namespace Iceshrimp.Backend.Core.Database.Tables; [Table("notification")] [Index("Type")] [Index("IsRead")] [Index("NotifierId")] [Index("NotifieeId")] [Index("CreatedAt")] [Index("AppAccessTokenId")] public class Notification { [Key] [Column("id")] [StringLength(32)] public string Id { get; set; } = null!; /// /// The created date of the Notification. /// [Column("createdAt")] public DateTime CreatedAt { get; set; } /// /// The ID of recipient user of the Notification. /// [Column("notifieeId")] [StringLength(32)] public string NotifieeId { get; set; } = null!; /// /// The ID of sender user of the Notification. /// [Column("notifierId")] [StringLength(32)] public string? NotifierId { get; set; } /// /// Whether the notification was read. /// [Column("isRead")] public bool IsRead { get; set; } [Column("type")] public NotificationType Type { get; set; } [Column("noteId")] [StringLength(32)] public string? NoteId { get; set; } [Column("reaction")] [StringLength(128)] public string? Reaction { get; set; } [Column("choice")] public int? Choice { get; set; } [Column("followRequestId")] [StringLength(32)] public string? FollowRequestId { get; set; } [Column("userGroupInvitationId")] [StringLength(32)] public string? UserGroupInvitationId { get; set; } [Column("customBody")] [StringLength(2048)] public string? CustomBody { get; set; } [Column("customHeader")] [StringLength(256)] public string? CustomHeader { get; set; } [Column("customIcon")] [StringLength(1024)] public string? CustomIcon { get; set; } [Column("appAccessTokenId")] [StringLength(32)] public string? AppAccessTokenId { get; set; } [ForeignKey("AppAccessTokenId")] [InverseProperty("Notifications")] public virtual AccessToken? AppAccessToken { get; set; } [ForeignKey("FollowRequestId")] [InverseProperty("Notifications")] public virtual FollowRequest? FollowRequest { get; set; } [ForeignKey("NoteId")] [InverseProperty("Notifications")] public virtual Note? Note { get; set; } [ForeignKey("NotifieeId")] [InverseProperty("NotificationNotifiees")] public virtual User Notifiee { get; set; } = null!; [ForeignKey("NotifierId")] [InverseProperty("NotificationNotifiers")] public virtual User? Notifier { get; set; } [ForeignKey("UserGroupInvitationId")] [InverseProperty("Notifications")] public virtual UserGroupInvitation? UserGroupInvitation { get; set; } [PgName("notification_type_enum")] public enum NotificationType { [PgName("follow")] Follow, [PgName("mention")] Mention, [PgName("reply")] Reply, [PgName("renote")] Renote, [PgName("quote")] Quote, [PgName("reaction")] Reaction, [PgName("pollVote")] PollVote, [PgName("pollEnded")] PollEnded, [PgName("receiveFollowRequest")] FollowRequestReceived, [PgName("followRequestAccepted")] FollowRequestAccepted, [PgName("groupInvited")] GroupInvited, [PgName("app")] App, } }