2021-11-30 02:35:21 +00:00
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
|
|
using NodaTime;
|
|
|
|
|
|
|
|
namespace PluralKit.Core;
|
|
|
|
|
|
|
|
public class SystemConfig
|
|
|
|
{
|
|
|
|
public SystemId Id { get; }
|
|
|
|
public string UiTz { get; set; }
|
|
|
|
public bool PingsEnabled { get; }
|
|
|
|
public int? LatchTimeout { get; }
|
2021-12-01 16:48:49 +00:00
|
|
|
public bool MemberDefaultPrivate { get; }
|
|
|
|
public bool GroupDefaultPrivate { get; }
|
2021-12-06 09:01:42 +00:00
|
|
|
public bool ShowPrivateInfo { get; }
|
2021-11-30 02:35:21 +00:00
|
|
|
public int? MemberLimitOverride { get; }
|
|
|
|
public int? GroupLimitOverride { get; }
|
|
|
|
|
|
|
|
public DateTimeZone Zone => DateTimeZoneProviders.Tzdb.GetZoneOrNull(UiTz);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class SystemConfigExt
|
|
|
|
{
|
|
|
|
public static JObject ToJson(this SystemConfig cfg)
|
|
|
|
{
|
|
|
|
var o = new JObject();
|
|
|
|
|
|
|
|
o.Add("timezone", cfg.UiTz);
|
|
|
|
o.Add("pings_enabled", cfg.PingsEnabled);
|
|
|
|
o.Add("latch_timeout", cfg.LatchTimeout);
|
2021-12-01 16:48:49 +00:00
|
|
|
o.Add("member_default_private", cfg.MemberDefaultPrivate);
|
|
|
|
o.Add("group_default_private", cfg.GroupDefaultPrivate);
|
2021-12-06 09:01:42 +00:00
|
|
|
o.Add("show_private_info", cfg.ShowPrivateInfo);
|
2021-11-30 02:35:21 +00:00
|
|
|
o.Add("member_limit", cfg.MemberLimitOverride ?? Limits.MaxMemberCount);
|
|
|
|
o.Add("group_limit", cfg.GroupLimitOverride ?? Limits.MaxGroupCount);
|
|
|
|
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
}
|