From cf455ed8de20bbee011289223e7d8d5775dfd69e Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Tue, 5 Sep 2023 06:28:52 +0200 Subject: Media moderator PoC works, abstract command handling to library --- .../StateEventTypes/MediaPolicyStateEventData.cs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'ExampleBots/MediaModeratorPoC/Bot/StateEventTypes/MediaPolicyStateEventData.cs') diff --git a/ExampleBots/MediaModeratorPoC/Bot/StateEventTypes/MediaPolicyStateEventData.cs b/ExampleBots/MediaModeratorPoC/Bot/StateEventTypes/MediaPolicyStateEventData.cs index 812ccf2..f37d33c 100644 --- a/ExampleBots/MediaModeratorPoC/Bot/StateEventTypes/MediaPolicyStateEventData.cs +++ b/ExampleBots/MediaModeratorPoC/Bot/StateEventTypes/MediaPolicyStateEventData.cs @@ -4,15 +4,20 @@ using LibMatrix.Interfaces; namespace MediaModeratorPoC.Bot.StateEventTypes; - +[MatrixEvent(EventName = "gay.rory.media_moderator_poc.rule.homeserver")] [MatrixEvent(EventName = "gay.rory.media_moderator_poc.rule.media")] public class MediaPolicyStateEventData : IStateEventType { /// - /// Entity this ban applies to, can use * and ? as globs. - /// This is an MXC URI. + /// This is an MXC URI, hashed with SHA3-256. /// [JsonPropertyName("entity")] - public string Entity { get; set; } + public byte[] Entity { get; set; } + + /// + /// Server this ban applies to, can use * and ? as globs. + /// + [JsonPropertyName("server_entity")] + public string? ServerEntity { get; set; } /// /// Reason this user is banned @@ -21,10 +26,10 @@ public class MediaPolicyStateEventData : IStateEventType { public string? Reason { get; set; } /// - /// Suggested action to take + /// Suggested action to take, one of `ban`, `kick`, `mute`, `redact`, `spoiler`, `warn` or `warn_admins` /// [JsonPropertyName("recommendation")] - public string? Recommendation { get; set; } + public string Recommendation { get; set; } = "warn"; /// /// Expiry time in milliseconds since the unix epoch, or null if the ban has no expiry. @@ -39,6 +44,9 @@ public class MediaPolicyStateEventData : IStateEventType { [JsonPropertyName("gay.rory.matrix_room_utils.readable_expiry_time_utc")] public DateTime? ExpiryDateTime { get => Expiry == null ? null : DateTimeOffset.FromUnixTimeMilliseconds(Expiry.Value).DateTime; - set => Expiry = ((DateTimeOffset)value).ToUnixTimeMilliseconds(); + set => Expiry = value is null ? null : ((DateTimeOffset)value).ToUnixTimeMilliseconds(); } + + [JsonPropertyName("file_hash")] + public byte[]? FileHash { get; set; } } -- cgit 1.4.1