From 3e934eee892f69a8f78b94950993000522702769 Mon Sep 17 00:00:00 2001 From: "Emma [it/its]@Rory&" Date: Thu, 23 Nov 2023 05:42:33 +0100 Subject: Moderation bot work --- .../Spec/Ephemeral/PresenceStateEventContent.cs | 18 ++++++++--------- .../EventTypes/Spec/RoomMessageEventContent.cs | 19 +++++++++++++++--- .../State/Policy/PolicyRuleStateEventContent.cs | 23 +++++++++++++++++----- 3 files changed, 43 insertions(+), 17 deletions(-) (limited to 'LibMatrix/EventTypes/Spec') diff --git a/LibMatrix/EventTypes/Spec/Ephemeral/PresenceStateEventContent.cs b/LibMatrix/EventTypes/Spec/Ephemeral/PresenceStateEventContent.cs index 3e4a5cd..558e4fc 100644 --- a/LibMatrix/EventTypes/Spec/Ephemeral/PresenceStateEventContent.cs +++ b/LibMatrix/EventTypes/Spec/Ephemeral/PresenceStateEventContent.cs @@ -4,17 +4,17 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = "m.presence")] -public class PresenceEventContent : TimelineEventContent { - [JsonPropertyName("presence")] - public string Presence { get; set; } +public class PresenceEventContent : EventContent { + [JsonPropertyName("presence"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? Presence { get; set; } [JsonPropertyName("last_active_ago")] public long LastActiveAgo { get; set; } [JsonPropertyName("currently_active")] public bool CurrentlyActive { get; set; } - [JsonPropertyName("status_msg")] - public string StatusMessage { get; set; } - [JsonPropertyName("avatar_url")] - public string AvatarUrl { get; set; } - [JsonPropertyName("displayname")] - public string DisplayName { get; set; } + [JsonPropertyName("status_msg"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? StatusMessage { get; set; } + [JsonPropertyName("avatar_url"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? AvatarUrl { get; set; } + [JsonPropertyName("displayname"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? DisplayName { get; set; } } diff --git a/LibMatrix/EventTypes/Spec/RoomMessageEventContent.cs b/LibMatrix/EventTypes/Spec/RoomMessageEventContent.cs index 1938b3e..8a22489 100644 --- a/LibMatrix/EventTypes/Spec/RoomMessageEventContent.cs +++ b/LibMatrix/EventTypes/Spec/RoomMessageEventContent.cs @@ -17,16 +17,29 @@ public class RoomMessageEventContent : TimelineEventContent { public string MessageType { get; set; } = "m.notice"; [JsonPropertyName("formatted_body")] - public string FormattedBody { get; set; } + public string? FormattedBody { get; set; } [JsonPropertyName("format")] - public string Format { get; set; } + public string? Format { get; set; } /// /// Media URI for this message, if any /// [JsonPropertyName("url")] public string? Url { get; set; } - + public string? FileName { get; set; } + + [JsonPropertyName("info")] + public FileInfoStruct? FileInfo { get; set; } + + public class FileInfoStruct { + [JsonPropertyName("mimetype")] + public string? MimeType { get; set; } + [JsonPropertyName("size")] + public long Size { get; set; } + [JsonPropertyName("thumbnail_url")] + public string? ThumbnailUrl { get; set; } + } + } diff --git a/LibMatrix/EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs b/LibMatrix/EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs index 63f148c..757a9e9 100644 --- a/LibMatrix/EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs @@ -3,10 +3,23 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; -[MatrixEvent(EventName = "m.policy.rule.user")] -[MatrixEvent(EventName = "m.policy.rule.server")] -[MatrixEvent(EventName = "org.matrix.mjolnir.rule.server")] -public class PolicyRuleEventContent : TimelineEventContent { +//spec +[MatrixEvent(EventName = "m.policy.rule.server")] //spec +[MatrixEvent(EventName = "m.room.rule.server")] //??? +[MatrixEvent(EventName = "org.matrix.mjolnir.rule.server")] //legacy +public class ServerPolicyRuleEventContent : PolicyRuleEventContent { } + +[MatrixEvent(EventName = "m.policy.rule.user")] //spec +[MatrixEvent(EventName = "m.room.rule.user")] //??? +[MatrixEvent(EventName = "org.matrix.mjolnir.rule.user")] //legacy +public class UserPolicyRuleEventContent : PolicyRuleEventContent { } + +[MatrixEvent(EventName = "m.policy.rule.room")] //spec +[MatrixEvent(EventName = "m.room.rule.room")] //??? +[MatrixEvent(EventName = "org.matrix.mjolnir.rule.room")] //legacy +public class RoomPolicyRuleEventContent : PolicyRuleEventContent { } + +public abstract class PolicyRuleEventContent : EventContent { /// /// Entity this ban applies to, can use * and ? as globs. /// @@ -52,4 +65,4 @@ public static class PolicyRecommendationTypes { /// Mute this user /// public static string Mute = "support.feline.policy.recommendation_mute"; //stable prefix: m.mute, msc pending -} +} \ No newline at end of file -- cgit 1.4.1