2020-02-12 15:16:19 +01:00
|
|
|
|
using Dapper.Contrib.Extensions;
|
|
|
|
|
|
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
|
|
|
|
using NodaTime;
|
|
|
|
|
|
|
2021-08-07 16:39:32 -04:00
|
|
|
|
|
|
|
|
|
|
|
2020-02-12 15:16:19 +01:00
|
|
|
|
namespace PluralKit.Core {
|
2021-08-07 16:39:32 -04:00
|
|
|
|
|
|
|
|
|
|
public readonly struct SystemId: INumericId<SystemId, int>
|
|
|
|
|
|
{
|
|
|
|
|
|
public int Value { get; }
|
|
|
|
|
|
|
|
|
|
|
|
public SystemId(int value)
|
|
|
|
|
|
{
|
|
|
|
|
|
Value = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool Equals(SystemId other) => Value == other.Value;
|
|
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj) => obj is SystemId other && Equals(other);
|
|
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode() => Value;
|
|
|
|
|
|
|
|
|
|
|
|
public static bool operator ==(SystemId left, SystemId right) => left.Equals(right);
|
|
|
|
|
|
|
|
|
|
|
|
public static bool operator !=(SystemId left, SystemId right) => !left.Equals(right);
|
|
|
|
|
|
|
|
|
|
|
|
public int CompareTo(SystemId other) => Value.CompareTo(other.Value);
|
|
|
|
|
|
|
|
|
|
|
|
public override string ToString() => $"System #{Value}";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-12 15:16:19 +01:00
|
|
|
|
public class PKSystem
|
|
|
|
|
|
{
|
|
|
|
|
|
// Additions here should be mirrored in SystemStore::Save
|
2020-06-14 21:37:04 +02:00
|
|
|
|
[Key] public SystemId Id { get; }
|
2020-06-13 13:11:08 +02:00
|
|
|
|
public string Hid { get; }
|
2020-06-29 14:39:19 +02:00
|
|
|
|
public string Name { get; }
|
|
|
|
|
|
public string Description { get; }
|
|
|
|
|
|
public string Tag { get; }
|
|
|
|
|
|
public string AvatarUrl { get; }
|
2021-08-02 13:46:12 -04:00
|
|
|
|
public string BannerImage { get; }
|
2021-03-28 12:02:41 +02:00
|
|
|
|
public string Color { get; }
|
2020-06-29 14:39:19 +02:00
|
|
|
|
public string Token { get; }
|
2020-06-13 13:11:08 +02:00
|
|
|
|
public Instant Created { get; }
|
2020-06-13 13:06:41 +02:00
|
|
|
|
public string UiTz { get; set; }
|
2020-06-29 14:39:19 +02:00
|
|
|
|
public bool PingsEnabled { get; }
|
2020-12-08 12:57:17 +01:00
|
|
|
|
public int? LatchTimeout { get; }
|
2020-06-29 14:39:19 +02:00
|
|
|
|
public PrivacyLevel DescriptionPrivacy { get; }
|
|
|
|
|
|
public PrivacyLevel MemberListPrivacy { get;}
|
|
|
|
|
|
public PrivacyLevel FrontPrivacy { get; }
|
|
|
|
|
|
public PrivacyLevel FrontHistoryPrivacy { get; }
|
2020-08-20 21:43:17 +02:00
|
|
|
|
public PrivacyLevel GroupListPrivacy { get; }
|
2020-10-09 12:18:29 +02:00
|
|
|
|
public int? MemberLimitOverride { get; }
|
|
|
|
|
|
public int? GroupLimitOverride { get; }
|
2020-02-12 15:16:19 +01:00
|
|
|
|
|
|
|
|
|
|
[JsonIgnore] public DateTimeZone Zone => DateTimeZoneProviders.Tzdb.GetZoneOrNull(UiTz);
|
|
|
|
|
|
}
|
2020-08-05 20:24:51 +02:00
|
|
|
|
|
|
|
|
|
|
public static class PKSystemExt
|
|
|
|
|
|
{
|
|
|
|
|
|
public static string DescriptionFor(this PKSystem system, LookupContext ctx) =>
|
|
|
|
|
|
system.DescriptionPrivacy.Get(ctx, system.Description);
|
|
|
|
|
|
}
|
2020-03-21 08:04:41 -05:00
|
|
|
|
}
|