Foxnouns.NET/Foxnouns.Backend/Database/Models/User.cs

83 lines
2.4 KiB
C#
Raw Normal View History

using System.ComponentModel.DataAnnotations.Schema;
using Foxnouns.Backend.Utils;
using Newtonsoft.Json;
using NodaTime;
2024-05-27 15:53:54 +02:00
namespace Foxnouns.Backend.Database.Models;
public class User : BaseModel
{
public required string Username { get; set; }
2024-09-26 15:08:08 +02:00
public string Sid { get; set; } = string.Empty;
2024-05-27 15:53:54 +02:00
public string? DisplayName { get; set; }
public string? Bio { get; set; }
public string? MemberTitle { get; set; }
public string? Avatar { get; set; }
public string[] Links { get; set; } = [];
public bool ListHidden { get; set; }
2024-11-24 22:19:53 +01:00
public string? Timezone { get; set; }
2024-05-27 15:53:54 +02:00
public List<FieldEntry> Names { get; set; } = [];
public List<Pronoun> Pronouns { get; set; } = [];
public List<Field> Fields { get; set; } = [];
public Dictionary<Snowflake, CustomPreference> CustomPreferences { get; set; } = [];
2024-05-27 15:53:54 +02:00
2024-09-26 20:15:04 +02:00
public List<PrideFlag> Flags { get; set; } = [];
public List<UserFlag> ProfileFlags { get; set; } = [];
2024-05-27 15:53:54 +02:00
public UserRole Role { get; set; } = UserRole.User;
public string? Password { get; set; } // Password may be null if the user doesn't authenticate with an email address
2024-05-27 15:53:54 +02:00
public List<Member> Members { get; } = [];
public List<AuthMethod> AuthMethods { get; } = [];
2024-12-03 14:55:19 +01:00
public List<DataExport> DataExports { get; } = [];
2024-09-05 22:17:10 +02:00
public UserSettings Settings { get; set; } = new();
public required Instant LastActive { get; set; }
2024-09-26 15:08:08 +02:00
public Instant LastSidReroll { get; set; }
public bool Deleted { get; set; }
public Instant? DeletedAt { get; set; }
public Snowflake? DeletedBy { get; set; }
[NotMapped]
public bool? SelfDelete => Deleted ? DeletedBy != null : null;
public class CustomPreference
{
public required string Icon { get; set; }
public required string Tooltip { get; set; }
public bool Muted { get; set; }
public bool Favourite { get; set; }
// This type is generally serialized directly, so the converter is applied here.
[JsonConverter(typeof(ScreamingSnakeCaseEnumConverter))]
public PreferenceSize Size { get; set; }
}
2024-12-03 14:55:19 +01:00
[NotMapped]
public static readonly Duration DeleteAfter = Duration.FromDays(30);
[NotMapped]
public static readonly Duration DeleteSuspendedAfter = Duration.FromDays(180);
2024-05-27 15:53:54 +02:00
}
public enum UserRole
{
User,
Moderator,
Admin,
}
public enum PreferenceSize
{
Large,
Normal,
Small,
2024-09-05 22:17:10 +02:00
}
public class UserSettings
{
public bool? DarkMode { get; set; } = null;
}