PluralKit/PluralKit.Core/Models/SystemConfig.cs

39 lines
1.2 KiB
C#
Raw Normal View History

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; }
public bool MemberDefaultPrivate { get; }
public bool GroupDefaultPrivate { get; }
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);
o.Add("member_default_private", cfg.MemberDefaultPrivate);
o.Add("group_default_private", cfg.GroupDefaultPrivate);
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;
}
}