2020-06-29 11:57:48 +00:00
|
|
|
|
#nullable enable
|
2021-04-21 21:57:19 +00:00
|
|
|
|
using System.Text.RegularExpressions;
|
2020-06-29 11:57:48 +00:00
|
|
|
|
|
|
|
|
|
using NodaTime;
|
|
|
|
|
|
|
|
|
|
namespace PluralKit.Core
|
|
|
|
|
{
|
2020-06-29 12:39:19 +00:00
|
|
|
|
public class MemberPatch: PatchObject
|
2020-06-29 11:57:48 +00:00
|
|
|
|
{
|
|
|
|
|
public Partial<string> Name { get; set; }
|
2021-06-08 17:37:44 +00:00
|
|
|
|
public Partial<string> Hid { get; set; }
|
2020-06-29 11:57:48 +00:00
|
|
|
|
public Partial<string?> DisplayName { get; set; }
|
2020-06-29 12:15:30 +00:00
|
|
|
|
public Partial<string?> AvatarUrl { get; set; }
|
2021-08-02 17:46:12 +00:00
|
|
|
|
public Partial<string?> BannerImage { get; set; }
|
2020-06-29 11:57:48 +00:00
|
|
|
|
public Partial<string?> Color { get; set; }
|
|
|
|
|
public Partial<LocalDate?> Birthday { get; set; }
|
|
|
|
|
public Partial<string?> Pronouns { get; set; }
|
|
|
|
|
public Partial<string?> Description { get; set; }
|
|
|
|
|
public Partial<ProxyTag[]> ProxyTags { get; set; }
|
|
|
|
|
public Partial<bool> KeepProxy { get; set; }
|
|
|
|
|
public Partial<int> MessageCount { get; set; }
|
2020-11-20 21:40:36 +00:00
|
|
|
|
public Partial<bool> AllowAutoproxy { get; set; }
|
2020-06-29 11:57:48 +00:00
|
|
|
|
public Partial<PrivacyLevel> Visibility { get; set; }
|
|
|
|
|
public Partial<PrivacyLevel> NamePrivacy { get; set; }
|
|
|
|
|
public Partial<PrivacyLevel> DescriptionPrivacy { get; set; }
|
|
|
|
|
public Partial<PrivacyLevel> PronounPrivacy { get; set; }
|
|
|
|
|
public Partial<PrivacyLevel> BirthdayPrivacy { get; set; }
|
|
|
|
|
public Partial<PrivacyLevel> AvatarPrivacy { get; set; }
|
|
|
|
|
public Partial<PrivacyLevel> MetadataPrivacy { get; set; }
|
|
|
|
|
|
|
|
|
|
public override UpdateQueryBuilder Apply(UpdateQueryBuilder b) => b
|
|
|
|
|
.With("name", Name)
|
2021-06-08 17:37:44 +00:00
|
|
|
|
.With("hid", Hid)
|
2020-06-29 11:57:48 +00:00
|
|
|
|
.With("display_name", DisplayName)
|
2020-06-29 12:15:30 +00:00
|
|
|
|
.With("avatar_url", AvatarUrl)
|
2021-08-02 17:46:12 +00:00
|
|
|
|
.With("banner_image", BannerImage)
|
2020-06-29 11:57:48 +00:00
|
|
|
|
.With("color", Color)
|
|
|
|
|
.With("birthday", Birthday)
|
|
|
|
|
.With("pronouns", Pronouns)
|
|
|
|
|
.With("description", Description)
|
|
|
|
|
.With("proxy_tags", ProxyTags)
|
|
|
|
|
.With("keep_proxy", KeepProxy)
|
|
|
|
|
.With("message_count", MessageCount)
|
2020-11-20 21:40:36 +00:00
|
|
|
|
.With("allow_autoproxy", AllowAutoproxy)
|
2020-06-29 11:57:48 +00:00
|
|
|
|
.With("member_visibility", Visibility)
|
|
|
|
|
.With("name_privacy", NamePrivacy)
|
|
|
|
|
.With("description_privacy", DescriptionPrivacy)
|
|
|
|
|
.With("pronoun_privacy", PronounPrivacy)
|
|
|
|
|
.With("birthday_privacy", BirthdayPrivacy)
|
|
|
|
|
.With("avatar_privacy", AvatarPrivacy)
|
|
|
|
|
.With("metadata_privacy", MetadataPrivacy);
|
2021-04-21 21:57:19 +00:00
|
|
|
|
|
|
|
|
|
public new void CheckIsValid()
|
|
|
|
|
{
|
|
|
|
|
if (AvatarUrl.Value != null && !MiscUtils.TryMatchUri(AvatarUrl.Value, out var avatarUri))
|
|
|
|
|
throw new InvalidPatchException("avatar_url");
|
2021-08-02 17:46:12 +00:00
|
|
|
|
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 11:57:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|