2020-06-29 21:51:12 +00:00
|
|
|
|
#nullable enable
|
2021-04-21 21:57:19 +00:00
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
2020-06-29 21:51:12 +00:00
|
|
|
|
namespace PluralKit.Core
|
|
|
|
|
{
|
|
|
|
|
public class GroupPatch: PatchObject
|
|
|
|
|
{
|
|
|
|
|
public Partial<string> Name { get; set; }
|
2021-07-08 14:04:05 +00:00
|
|
|
|
public Partial<string> Hid { get; set; }
|
2020-08-20 19:43:17 +00:00
|
|
|
|
public Partial<string?> DisplayName { get; set; }
|
2020-06-29 21:51:12 +00:00
|
|
|
|
public Partial<string?> Description { get; set; }
|
2020-07-07 17:45:26 +00:00
|
|
|
|
public Partial<string?> Icon { get; set; }
|
2021-08-02 17:46:12 +00:00
|
|
|
|
public Partial<string?> BannerImage { get; set; }
|
2021-03-28 10:02:41 +00:00
|
|
|
|
public Partial<string?> Color { get; set; }
|
2020-07-07 17:45:26 +00:00
|
|
|
|
|
|
|
|
|
public Partial<PrivacyLevel> DescriptionPrivacy { get; set; }
|
|
|
|
|
public Partial<PrivacyLevel> IconPrivacy { get; set; }
|
2020-08-20 19:43:17 +00:00
|
|
|
|
public Partial<PrivacyLevel> ListPrivacy { get; set; }
|
2020-07-07 17:45:26 +00:00
|
|
|
|
public Partial<PrivacyLevel> Visibility { get; set; }
|
2020-06-29 21:51:12 +00:00
|
|
|
|
|
|
|
|
|
public override UpdateQueryBuilder Apply(UpdateQueryBuilder b) => b
|
|
|
|
|
.With("name", Name)
|
2021-07-08 14:04:05 +00:00
|
|
|
|
.With("hid", Hid)
|
2020-08-20 19:43:17 +00:00
|
|
|
|
.With("display_name", DisplayName)
|
2020-07-07 17:45:26 +00:00
|
|
|
|
.With("description", Description)
|
|
|
|
|
.With("icon", Icon)
|
2021-08-02 17:46:12 +00:00
|
|
|
|
.With("banner_image", BannerImage)
|
2021-03-28 10:02:41 +00:00
|
|
|
|
.With("color", Color)
|
2020-07-07 17:45:26 +00:00
|
|
|
|
.With("description_privacy", DescriptionPrivacy)
|
|
|
|
|
.With("icon_privacy", IconPrivacy)
|
2020-08-20 19:43:17 +00:00
|
|
|
|
.With("list_privacy", ListPrivacy)
|
2020-07-07 17:45:26 +00:00
|
|
|
|
.With("visibility", Visibility);
|
2021-04-21 21:57:19 +00:00
|
|
|
|
|
|
|
|
|
public new void CheckIsValid()
|
|
|
|
|
{
|
|
|
|
|
if (Icon.Value != null && !MiscUtils.TryMatchUri(Icon.Value, out var avatarUri))
|
2021-08-02 17:46:12 +00:00
|
|
|
|
throw new InvalidPatchException("icon");
|
|
|
|
|
if (BannerImage.Value != null && !MiscUtils.TryMatchUri(BannerImage.Value, out var bannerImage))
|
|
|
|
|
throw new InvalidPatchException("banner");
|
2021-04-21 21:57:19 +00:00
|
|
|
|
if (Color.Value != null && (!Regex.IsMatch(Color.Value, "^[0-9a-fA-F]{6}$")))
|
|
|
|
|
throw new InvalidPatchException("color");
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-29 21:51:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|