From e5591eef3850a9796cc87386128651a828b70697 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Fri, 6 Oct 2023 18:29:15 +0200 Subject: Small refactors --- .../StateEventTypes/BasePolicy.cs | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 ExampleBots/MediaModeratorPoC/StateEventTypes/BasePolicy.cs (limited to 'ExampleBots/MediaModeratorPoC/StateEventTypes/BasePolicy.cs') diff --git a/ExampleBots/MediaModeratorPoC/StateEventTypes/BasePolicy.cs b/ExampleBots/MediaModeratorPoC/StateEventTypes/BasePolicy.cs new file mode 100644 index 0000000..048c1d0 --- /dev/null +++ b/ExampleBots/MediaModeratorPoC/StateEventTypes/BasePolicy.cs @@ -0,0 +1,42 @@ +using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; +using LibMatrix; + +namespace MediaModeratorPoC.StateEventTypes; + +public abstract class BasePolicy : StateEvent { + /// + /// Entity this policy applies to + /// + [JsonPropertyName("entity")] + public string Entity { get; set; } + + /// + /// Reason this policy exists + /// + [JsonPropertyName("reason")] + public string? Reason { get; set; } + + /// + /// Suggested action to take, one of `ban`, `kick`, `mute`, `redact`, `spoiler`, `warn` or `warn_admins` + /// + [JsonPropertyName("recommendation")] + [AllowedValues("ban", "kick", "mute", "redact", "spoiler", "warn", "warn_admins")] + public string Recommendation { get; set; } = "warn"; + + /// + /// Expiry time in milliseconds since the unix epoch, or null if the ban has no expiry. + /// + [JsonPropertyName("support.feline.policy.expiry.rev.2")] //stable prefix: expiry, msc pending + public long? Expiry { get; set; } + + //utils + /// + /// Readable expiry time, provided for easy interaction + /// + [JsonPropertyName("gay.rory.matrix_room_utils.readable_expiry_time_utc")] + public DateTime? ExpiryDateTime { + get => Expiry == null ? null : DateTimeOffset.FromUnixTimeMilliseconds(Expiry.Value).DateTime; + set => Expiry = value is null ? null : ((DateTimeOffset)value).ToUnixTimeMilliseconds(); + } +} -- cgit 1.4.1