using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using API.Entities.Enums; using API.Entities.Interfaces; using API.Entities.Scrobble; using Microsoft.AspNetCore.Identity; namespace API.Entities; public class AppUser : IdentityUser, IHasConcurrencyToken { public DateTime Created { get; set; } = DateTime.Now; public DateTime CreatedUtc { get; set; } = DateTime.UtcNow; public DateTime LastActive { get; set; } public DateTime LastActiveUtc { get; set; } public ICollection Libraries { get; set; } = null!; public ICollection UserRoles { get; set; } = null!; public ICollection Progresses { get; set; } = null!; public ICollection Ratings { get; set; } = null!; public ICollection ChapterRatings { get; set; } = null!; public AppUserPreferences UserPreferences { get; set; } = null!; /// /// Bookmarks associated with this User /// public ICollection Bookmarks { get; set; } = null!; /// /// Reading lists associated with this user /// public ICollection ReadingLists { get; set; } = null!; /// /// Collections associated with this user /// public ICollection Collections { get; set; } = null!; /// /// A list of Series the user want's to read /// public ICollection WantToRead { get; set; } = null!; /// /// A list of Devices which allows the user to send files to /// public ICollection Devices { get; set; } = null!; /// /// A list of Table of Contents for a given Chapter /// public ICollection TableOfContents { get; set; } = null!; /// /// An API Key to interact with external services, like OPDS /// public string? ApiKey { get; set; } /// /// The confirmation token for the user (invite). This will be set to null after the user confirms. /// public string? ConfirmationToken { get; set; } /// /// The highest age rating the user has access to. Not applicable for admins /// public AgeRating AgeRestriction { get; set; } = AgeRating.NotApplicable; /// /// If an age rating restriction is applied to the account, if Unknowns should be allowed for the user. Defaults to false. /// public bool AgeRestrictionIncludeUnknowns { get; set; } = false; /// /// The JWT for the user's AniList account. Expires after a year. /// /// Requires Kavita+ Subscription public string? AniListAccessToken { get; set; } /// /// The Username of the MAL user /// public string? MalUserName { get; set; } /// /// The Client ID for the user's MAL account. User should create a client on MAL for this. /// public string? MalAccessToken { get; set; } /// /// Has the user ran Scrobble Event Generation /// /// Only applicable for Kavita+ and when a Token is present public bool HasRunScrobbleEventGeneration { get; set; } /// /// The timestamp of when Scrobble Event Generation ran (Utc) /// /// Kavita+ only public DateTime ScrobbleEventGenerationRan { get; set; } /// /// A list of Series the user doesn't want scrobbling for /// public ICollection ScrobbleHolds { get; set; } = null!; /// /// A collection of user Smart Filters for their account /// public ICollection SmartFilters { get; set; } = null!; /// /// An ordered list of Streams (pre-configured) or Smart Filters that makes up the User's Dashboard /// public IList DashboardStreams { get; set; } = null!; /// /// An ordered list of Streams (pre-configured) or Smart Filters that makes up the User's SideNav /// public IList SideNavStreams { get; set; } = null!; public IList ExternalSources { get; set; } = null!; /// [ConcurrencyCheck] public uint RowVersion { get; private set; } /// public void OnSavingChanges() { RowVersion++; } public void UpdateLastActive() { LastActive = DateTime.Now; LastActiveUtc = DateTime.UtcNow; } }