about summary refs log tree commit diff
path: root/LibMatrix.EventTypes/Spec/State
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-05-02 16:21:13 +0200
committerRory& <root@rory.gay>2025-05-02 16:21:13 +0200
commit2fde2d5f961eabf3167280ba55786cdb6b38f2c0 (patch)
treedaa6d20e205f8c1f400850c7e10439a0f0d295be /LibMatrix.EventTypes/Spec/State
parentExtensible message relations, mauping support (diff)
downloadLibMatrix-2fde2d5f961eabf3167280ba55786cdb6b38f2c0.tar.xz
Add support for ignoring users, add user/room/event reporting
Diffstat (limited to 'LibMatrix.EventTypes/Spec/State')
-rw-r--r--LibMatrix.EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs13
1 files changed, 12 insertions, 1 deletions
diff --git a/LibMatrix.EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs b/LibMatrix.EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs

index 0cb4a25..6f8c194 100644 --- a/LibMatrix.EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs
@@ -97,16 +97,27 @@ public abstract class PolicyRuleEventContent : EventContent { public Regex? GetEntityRegex() => Entity is null ? null : new(Entity.Replace(".", "\\.").Replace("*", ".*").Replace("?", ".")); + public bool IsGlobRule() => + Entity != null + && (Entity.Contains('*') || Entity.Contains('?')); + public bool EntityMatches(string entity) => Entity != null && ( Entity == entity || ( - Entity.Contains("*") || Entity.Contains("?") + IsGlobRule() ? GetEntityRegex()!.IsMatch(entity) : entity == Entity ) ); + + public string? GetNormalizedRecommendation() { + if (Recommendation is "m.ban" or "org.matrix.mjolnir.ban") + return PolicyRecommendationTypes.Ban; + + return Recommendation; + } } public static class PolicyRecommendationTypes {