PolicyRuleStateEventData.cs (1618B)
1 using System.Text.Json.Serialization; 2 3 namespace MatrixRoomUtils.Core.StateEventTypes; 4 5 public class PolicyRuleStateEventData 6 { 7 /// <summary> 8 /// Entity this ban applies to, can use * and ? as globs. 9 /// </summary> 10 [JsonPropertyName("entity")] 11 public string? Entity { get; set; } 12 /// <summary> 13 /// Reason this user is banned 14 /// </summary> 15 [JsonPropertyName("reason")] 16 public string? Reason { get; set; } 17 /// <summary> 18 /// Suggested action to take 19 /// </summary> 20 [JsonPropertyName("recommendation")] 21 public string? Recommendation { get; set; } 22 23 /// <summary> 24 /// Expiry time in milliseconds since the unix epoch, or null if the ban has no expiry. 25 /// </summary> 26 [JsonPropertyName("support.feline.policy.expiry.rev.2")] //stable prefix: expiry, msc pending 27 public long? Expiry { get; set; } 28 29 30 //utils 31 /// <summary> 32 /// Readable expiry time, provided for easy interaction 33 /// </summary> 34 [JsonPropertyName("gay.rory.matrix_room_utils.readable_expiry_time_utc")] 35 public DateTime? ExpiryDateTime 36 { 37 get => Expiry == null ? null : DateTimeOffset.FromUnixTimeMilliseconds(Expiry.Value).DateTime; 38 set => Expiry = ((DateTimeOffset) value).ToUnixTimeMilliseconds(); 39 } 40 } 41 42 public static class PolicyRecommendationTypes 43 { 44 /// <summary> 45 /// Ban this user 46 /// </summary> 47 public static string Ban = "m.ban"; 48 /// <summary> 49 /// Mute this user 50 /// </summary> 51 public static string Mute = "support.feline.policy.recommendation_mute"; //stable prefix: m.mute, msc pending 52 }