2020-06-29 12:39:19 +00:00
|
|
|
|
#nullable enable
|
2021-04-21 21:57:19 +00:00
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
2020-06-29 12:39:19 +00:00
|
|
|
|
namespace PluralKit.Core
|
|
|
|
|
{
|
|
|
|
|
public class SystemPatch: PatchObject
|
|
|
|
|
{
|
|
|
|
|
public Partial<string?> Name { get; set; }
|
|
|
|
|
public Partial<string?> Description { get; set; }
|
|
|
|
|
public Partial<string?> Tag { get; set; }
|
|
|
|
|
public Partial<string?> AvatarUrl { get; set; }
|
2021-03-28 10:02:41 +00:00
|
|
|
|
public Partial<string?> Color { get; set; }
|
2020-06-29 12:39:19 +00:00
|
|
|
|
public Partial<string?> Token { get; set; }
|
|
|
|
|
public Partial<string> UiTz { get; set; }
|
|
|
|
|
public Partial<PrivacyLevel> DescriptionPrivacy { get; set; }
|
|
|
|
|
public Partial<PrivacyLevel> MemberListPrivacy { get; set; }
|
2020-08-20 19:43:17 +00:00
|
|
|
|
public Partial<PrivacyLevel> GroupListPrivacy { get; set; }
|
2020-06-29 12:39:19 +00:00
|
|
|
|
public Partial<PrivacyLevel> FrontPrivacy { get; set; }
|
|
|
|
|
public Partial<PrivacyLevel> FrontHistoryPrivacy { get; set; }
|
|
|
|
|
public Partial<bool> PingsEnabled { get; set; }
|
2020-12-08 11:57:17 +00:00
|
|
|
|
public Partial<int?> LatchTimeout { get; set; }
|
2020-06-29 12:39:19 +00:00
|
|
|
|
|
|
|
|
|
public override UpdateQueryBuilder Apply(UpdateQueryBuilder b) => b
|
|
|
|
|
.With("name", Name)
|
|
|
|
|
.With("description", Description)
|
|
|
|
|
.With("tag", Tag)
|
|
|
|
|
.With("avatar_url", AvatarUrl)
|
2021-03-28 10:02:41 +00:00
|
|
|
|
.With("color", Color)
|
2020-06-29 12:39:19 +00:00
|
|
|
|
.With("token", Token)
|
|
|
|
|
.With("ui_tz", UiTz)
|
|
|
|
|
.With("description_privacy", DescriptionPrivacy)
|
|
|
|
|
.With("member_list_privacy", MemberListPrivacy)
|
2020-08-20 19:43:17 +00:00
|
|
|
|
.With("group_list_privacy", GroupListPrivacy)
|
2020-06-29 12:39:19 +00:00
|
|
|
|
.With("front_privacy", FrontPrivacy)
|
|
|
|
|
.With("front_history_privacy", FrontHistoryPrivacy)
|
2020-11-21 00:44:15 +00:00
|
|
|
|
.With("pings_enabled", PingsEnabled)
|
|
|
|
|
.With("latch_timeout", LatchTimeout);
|
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");
|
|
|
|
|
if (Color.Value != null && (!Regex.IsMatch(Color.Value, "^[0-9a-fA-F]{6}$")))
|
|
|
|
|
throw new InvalidPatchException("color");
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-29 12:39:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|