2021-08-27 11:03:47 -04:00
|
|
|
using NodaTime;
|
2020-06-29 23:51:12 +02:00
|
|
|
|
2021-08-07 16:39:32 -04:00
|
|
|
|
|
|
|
|
2020-06-29 23:51:12 +02:00
|
|
|
namespace PluralKit.Core
|
|
|
|
{
|
2021-08-07 16:39:32 -04:00
|
|
|
public readonly struct GroupId: INumericId<GroupId, int>
|
|
|
|
{
|
|
|
|
public int Value { get; }
|
|
|
|
|
|
|
|
public GroupId(int value)
|
|
|
|
{
|
|
|
|
Value = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool Equals(GroupId other) => Value == other.Value;
|
|
|
|
|
|
|
|
public override bool Equals(object obj) => obj is GroupId other && Equals(other);
|
|
|
|
|
|
|
|
public override int GetHashCode() => Value;
|
|
|
|
|
|
|
|
public static bool operator ==(GroupId left, GroupId right) => left.Equals(right);
|
|
|
|
|
|
|
|
public static bool operator !=(GroupId left, GroupId right) => !left.Equals(right);
|
|
|
|
|
|
|
|
public int CompareTo(GroupId other) => Value.CompareTo(other.Value);
|
2021-08-27 11:03:47 -04:00
|
|
|
|
2021-08-07 16:39:32 -04:00
|
|
|
public override string ToString() => $"Group #{Value}";
|
|
|
|
}
|
|
|
|
|
|
|
|
#nullable enable
|
2020-06-29 23:51:12 +02:00
|
|
|
public class PKGroup
|
|
|
|
{
|
2020-08-21 17:08:49 +02:00
|
|
|
public GroupId Id { get; private set; }
|
|
|
|
public string Hid { get; private set; } = null!;
|
|
|
|
public SystemId System { get; private set; }
|
2020-06-29 23:51:12 +02:00
|
|
|
|
2020-08-21 17:08:49 +02:00
|
|
|
public string Name { get; private set; } = null!;
|
|
|
|
public string? DisplayName { get; private set; }
|
|
|
|
public string? Description { get; private set; }
|
|
|
|
public string? Icon { get; private set; }
|
2021-08-02 13:46:12 -04:00
|
|
|
public string? BannerImage { get; private set; }
|
2021-03-28 12:02:41 +02:00
|
|
|
public string? Color { get; private set; }
|
2020-07-07 19:45:26 +02:00
|
|
|
|
2020-08-21 17:08:49 +02:00
|
|
|
public PrivacyLevel DescriptionPrivacy { get; private set; }
|
|
|
|
public PrivacyLevel IconPrivacy { get; private set; }
|
|
|
|
public PrivacyLevel ListPrivacy { get; private set; }
|
|
|
|
public PrivacyLevel Visibility { get; private set; }
|
2021-08-27 11:03:47 -04:00
|
|
|
|
2020-08-21 17:08:49 +02:00
|
|
|
public Instant Created { get; private set; }
|
2020-06-29 23:51:12 +02:00
|
|
|
}
|
2020-08-21 18:31:22 +02:00
|
|
|
|
|
|
|
public static class PKGroupExt
|
|
|
|
{
|
|
|
|
public static string? DescriptionFor(this PKGroup group, LookupContext ctx) =>
|
|
|
|
group.DescriptionPrivacy.Get(ctx, group.Description);
|
2021-08-27 11:03:47 -04:00
|
|
|
|
2020-08-21 18:31:22 +02:00
|
|
|
public static string? IconFor(this PKGroup group, LookupContext ctx) =>
|
2021-08-01 12:51:54 -04:00
|
|
|
group.IconPrivacy.Get(ctx, group.Icon?.TryGetCleanCdnUrl());
|
2020-08-21 18:31:22 +02:00
|
|
|
}
|
2020-06-29 23:51:12 +02:00
|
|
|
}
|