2019-04-19 18:48:37 +00:00
|
|
|
using Dapper.Contrib.Extensions;
|
2019-07-09 18:39:29 +00:00
|
|
|
using Newtonsoft.Json;
|
2019-05-13 20:44:49 +00:00
|
|
|
using NodaTime;
|
|
|
|
using NodaTime.Text;
|
2019-04-19 18:48:37 +00:00
|
|
|
|
2019-08-14 05:16:48 +00:00
|
|
|
using PluralKit.Core;
|
|
|
|
|
2019-04-29 15:42:09 +00:00
|
|
|
namespace PluralKit
|
|
|
|
{
|
|
|
|
public class PKSystem
|
|
|
|
{
|
2019-08-09 08:12:38 +00:00
|
|
|
// Additions here should be mirrored in SystemStore::Save
|
2019-07-09 18:39:29 +00:00
|
|
|
[Key] [JsonIgnore] public int Id { get; set; }
|
|
|
|
[JsonProperty("id")] public string Hid { get; set; }
|
|
|
|
[JsonProperty("name")] public string Name { get; set; }
|
|
|
|
[JsonProperty("description")] public string Description { get; set; }
|
|
|
|
[JsonProperty("tag")] public string Tag { get; set; }
|
|
|
|
[JsonProperty("avatar_url")] public string AvatarUrl { get; set; }
|
|
|
|
[JsonIgnore] public string Token { get; set; }
|
|
|
|
[JsonProperty("created")] public Instant Created { get; set; }
|
|
|
|
[JsonProperty("tz")] public string UiTz { get; set; }
|
2019-04-29 17:43:09 +00:00
|
|
|
|
2019-08-14 05:16:48 +00:00
|
|
|
[JsonIgnore] public int MaxMemberNameLength => Tag != null ? Limits.MaxProxyNameLength - Tag.Length - 1 : Limits.MaxProxyNameLength;
|
2019-06-15 10:33:24 +00:00
|
|
|
|
2019-07-09 18:39:29 +00:00
|
|
|
[JsonIgnore] public DateTimeZone Zone => DateTimeZoneProviders.Tzdb.GetZoneOrNull(UiTz);
|
2019-04-19 18:48:37 +00:00
|
|
|
}
|
|
|
|
|
2019-04-29 15:42:09 +00:00
|
|
|
public class PKMember
|
|
|
|
{
|
2019-08-09 08:12:38 +00:00
|
|
|
// Additions here should be mirrored in MemberStore::Save
|
2019-07-09 18:39:29 +00:00
|
|
|
[JsonIgnore] public int Id { get; set; }
|
|
|
|
[JsonProperty("id")] public string Hid { get; set; }
|
|
|
|
[JsonIgnore] public int System { get; set; }
|
|
|
|
[JsonProperty("color")] public string Color { get; set; }
|
|
|
|
[JsonProperty("avatar_url")] public string AvatarUrl { get; set; }
|
|
|
|
[JsonProperty("name")] public string Name { get; set; }
|
2019-08-09 08:12:38 +00:00
|
|
|
[JsonProperty("display_name")] public string DisplayName { get; set; }
|
2019-07-09 18:39:29 +00:00
|
|
|
[JsonProperty("birthday")] public LocalDate? Birthday { get; set; }
|
|
|
|
[JsonProperty("pronouns")] public string Pronouns { get; set; }
|
|
|
|
[JsonProperty("description")] public string Description { get; set; }
|
|
|
|
[JsonProperty("prefix")] public string Prefix { get; set; }
|
|
|
|
[JsonProperty("suffix")] public string Suffix { get; set; }
|
|
|
|
[JsonProperty("created")] public Instant Created { get; set; }
|
2019-04-29 15:42:09 +00:00
|
|
|
|
|
|
|
/// Returns a formatted string representing the member's birthday, taking into account that a year of "0001" is hidden
|
2019-07-09 18:39:29 +00:00
|
|
|
[JsonIgnore] public string BirthdayString
|
2019-04-29 15:42:09 +00:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (Birthday == null) return null;
|
2019-05-13 20:44:49 +00:00
|
|
|
|
|
|
|
var format = LocalDatePattern.CreateWithInvariantCulture("MMM dd, yyyy");
|
|
|
|
if (Birthday?.Year == 1) format = LocalDatePattern.CreateWithInvariantCulture("MMM dd");
|
|
|
|
return format.Format(Birthday.Value);
|
2019-04-29 15:42:09 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-29 17:52:07 +00:00
|
|
|
|
2019-07-09 18:39:29 +00:00
|
|
|
[JsonIgnore] public bool HasProxyTags => Prefix != null || Suffix != null;
|
|
|
|
[JsonIgnore] public string ProxyString => $"{Prefix ?? ""}text{Suffix ?? ""}";
|
2019-08-09 08:12:38 +00:00
|
|
|
|
|
|
|
public string ProxyName(string systemTag)
|
|
|
|
{
|
|
|
|
if (systemTag == null) return DisplayName ?? Name;
|
|
|
|
return $"{DisplayName ?? Name} {systemTag}";
|
|
|
|
}
|
2019-04-19 18:48:37 +00:00
|
|
|
}
|
2019-06-13 14:53:04 +00:00
|
|
|
|
|
|
|
public class PKSwitch
|
|
|
|
{
|
|
|
|
public int Id { get; set; }
|
|
|
|
public int System { get; set; }
|
|
|
|
public Instant Timestamp { get; set; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public class PKSwitchMember
|
|
|
|
{
|
|
|
|
public int Id { get; set; }
|
|
|
|
public int Switch { get; set; }
|
|
|
|
public int Member { get; set; }
|
|
|
|
}
|
2019-04-19 18:48:37 +00:00
|
|
|
}
|