about summary refs log tree commit diff
path: root/ExampleBots/MediaModeratorPoC/StateEventTypes/BasePolicy.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ExampleBots/MediaModeratorPoC/StateEventTypes/BasePolicy.cs')
-rw-r--r--ExampleBots/MediaModeratorPoC/StateEventTypes/BasePolicy.cs42
1 files changed, 42 insertions, 0 deletions
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 {
+    /// <summary>
+    ///     Entity this policy applies to
+    /// </summary>
+    [JsonPropertyName("entity")]
+    public string Entity { get; set; }
+
+    /// <summary>
+    ///     Reason this policy exists
+    /// </summary>
+    [JsonPropertyName("reason")]
+    public string? Reason { get; set; }
+
+    /// <summary>
+    ///     Suggested action to take, one of `ban`, `kick`, `mute`, `redact`, `spoiler`, `warn` or `warn_admins`
+    /// </summary>
+    [JsonPropertyName("recommendation")]
+    [AllowedValues("ban", "kick", "mute", "redact", "spoiler", "warn", "warn_admins")]
+    public string Recommendation { get; set; } = "warn";
+
+    /// <summary>
+    ///     Expiry time in milliseconds since the unix epoch, or null if the ban has no expiry.
+    /// </summary>
+    [JsonPropertyName("support.feline.policy.expiry.rev.2")] //stable prefix: expiry, msc pending
+    public long? Expiry { get; set; }
+
+    //utils
+    /// <summary>
+    ///     Readable expiry time, provided for easy interaction
+    /// </summary>
+    [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();
+    }
+}