feat(bot): Case insensitive proxy tags matching (#490)

This commit is contained in:
Katrix 2022-11-23 09:48:24 +01:00 committed by GitHub
parent 09ac002d26
commit 4f0236d766
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 89 additions and 19 deletions

View file

@ -17,6 +17,7 @@ public class SystemConfigPatch: PatchObject
public Partial<int?> MemberLimitOverride { get; set; }
public Partial<int?> GroupLimitOverride { get; set; }
public Partial<string[]> DescriptionTemplates { get; set; }
public Partial<bool> CaseSensitiveProxyTags { get; set; }
public override Query Apply(Query q) => q.ApplyPatch(wrapper => wrapper
@ -29,6 +30,7 @@ public class SystemConfigPatch: PatchObject
.With("member_limit_override", MemberLimitOverride)
.With("group_limit_override", GroupLimitOverride)
.With("description_templates", DescriptionTemplates)
.With("case_sensitive_proxy_tags", CaseSensitiveProxyTags)
);
public new void AssertIsValid()
@ -78,6 +80,9 @@ public class SystemConfigPatch: PatchObject
if (DescriptionTemplates.IsPresent)
o.Add("description_templates", JArray.FromObject(DescriptionTemplates.Value));
if (CaseSensitiveProxyTags.IsPresent)
o.Add("case_sensitive_proxy_tags", CaseSensitiveProxyTags.Value);
return o;
}
@ -103,6 +108,9 @@ public class SystemConfigPatch: PatchObject
if (o.ContainsKey("description_templates"))
patch.DescriptionTemplates = o.Value<JArray>("description_templates").Select(x => x.Value<string>()).ToArray();
if (o.ContainsKey("case_sensitive_proxy_tags"))
patch.CaseSensitiveProxyTags = o.Value<bool>("case_sensitive_proxy_tags");
return patch;
}
}

View file

@ -18,6 +18,8 @@ public class SystemConfig
public ICollection<string> DescriptionTemplates { get; }
public DateTimeZone Zone => DateTimeZoneProviders.Tzdb.GetZoneOrNull(UiTz);
public bool CaseSensitiveProxyTags { get; set; }
}
public static class SystemConfigExt
@ -34,6 +36,7 @@ public static class SystemConfigExt
o.Add("show_private_info", cfg.ShowPrivateInfo);
o.Add("member_limit", cfg.MemberLimitOverride ?? Limits.MaxMemberCount);
o.Add("group_limit", cfg.GroupLimitOverride ?? Limits.MaxGroupCount);
o.Add("case_sensitive_proxy_tags", cfg.CaseSensitiveProxyTags);
o.Add("description_templates", JArray.FromObject(cfg.DescriptionTemplates));