From 6bd02248ccfbcb46960a6f39eaad23888d190eb5 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Fri, 15 Sep 2023 09:50:45 +0200 Subject: Some refactoring --- .../Common/MjolnirShortcodeEventData.cs | 2 +- .../StateEventTypes/Common/RoomEmotesEventData.cs | 2 +- .../Spec/CanonicalAliasEventContent.cs | 13 ++++++++++++ .../Spec/CanonicalAliasEventData.cs | 13 ------------ .../StateEventTypes/Spec/GuestAccessEventData.cs | 2 +- .../Spec/HistoryVisibilityEventData.cs | 2 +- .../StateEventTypes/Spec/JoinRulesEventData.cs | 2 +- .../Spec/PolicyRuleStateEventData.cs | 2 +- .../StateEventTypes/Spec/PresenceStateEventData.cs | 2 +- .../Spec/ProfileResponseEventData.cs | 2 +- .../StateEventTypes/Spec/RoomAliasEventData.cs | 2 +- .../StateEventTypes/Spec/RoomAvatarEventData.cs | 2 +- .../StateEventTypes/Spec/RoomCreateEventData.cs | 2 +- .../Spec/RoomEncryptionEventData.cs | 2 +- .../StateEventTypes/Spec/RoomMemberEventData.cs | 2 +- .../StateEventTypes/Spec/RoomMessageEventData.cs | 24 ++-------------------- .../StateEventTypes/Spec/RoomNameEventData.cs | 2 +- .../StateEventTypes/Spec/RoomPinnedEventData.cs | 2 +- .../Spec/RoomPowerLevelEventData.cs | 2 +- .../StateEventTypes/Spec/RoomTopicEventData.cs | 2 +- .../StateEventTypes/Spec/RoomTypingEventData.cs | 2 +- .../StateEventTypes/Spec/ServerACLEventData.cs | 2 +- .../StateEventTypes/Spec/SpaceChildEventData.cs | 2 +- .../StateEventTypes/Spec/SpaceParentEventData.cs | 2 +- LibMatrix/StateEventTypes/UnknownStateEventData.cs | 7 +++++++ 25 files changed, 43 insertions(+), 56 deletions(-) create mode 100644 LibMatrix/StateEventTypes/Spec/CanonicalAliasEventContent.cs delete mode 100644 LibMatrix/StateEventTypes/Spec/CanonicalAliasEventData.cs create mode 100644 LibMatrix/StateEventTypes/UnknownStateEventData.cs (limited to 'LibMatrix/StateEventTypes') diff --git a/LibMatrix/StateEventTypes/Common/MjolnirShortcodeEventData.cs b/LibMatrix/StateEventTypes/Common/MjolnirShortcodeEventData.cs index 7a4b3f3..ff11be7 100644 --- a/LibMatrix/StateEventTypes/Common/MjolnirShortcodeEventData.cs +++ b/LibMatrix/StateEventTypes/Common/MjolnirShortcodeEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Common; [MatrixEvent(EventName = "org.matrix.mjolnir.shortcode")] -public class MjolnirShortcodeEventData : IStateEventType { +public class MjolnirShortcodeEventContent : EventContent { [JsonPropertyName("shortcode")] public string? Shortcode { get; set; } } diff --git a/LibMatrix/StateEventTypes/Common/RoomEmotesEventData.cs b/LibMatrix/StateEventTypes/Common/RoomEmotesEventData.cs index ad65b0f..a056eda 100644 --- a/LibMatrix/StateEventTypes/Common/RoomEmotesEventData.cs +++ b/LibMatrix/StateEventTypes/Common/RoomEmotesEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Common; [MatrixEvent(EventName = "im.ponies.room_emotes")] -public class RoomEmotesEventData : IStateEventType { +public class RoomEmotesEventContent : EventContent { [JsonPropertyName("emoticons")] public Dictionary? Emoticons { get; set; } diff --git a/LibMatrix/StateEventTypes/Spec/CanonicalAliasEventContent.cs b/LibMatrix/StateEventTypes/Spec/CanonicalAliasEventContent.cs new file mode 100644 index 0000000..7a0e84c --- /dev/null +++ b/LibMatrix/StateEventTypes/Spec/CanonicalAliasEventContent.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; +using LibMatrix.Helpers; +using LibMatrix.Interfaces; + +namespace LibMatrix.StateEventTypes.Spec; + +[MatrixEvent(EventName = "m.room.canonical_alias")] +public class CanonicalAliasEventContent : EventContent { + [JsonPropertyName("alias")] + public string? Alias { get; set; } + [JsonPropertyName("alt_aliases")] + public string[]? AltAliases { get; set; } +} diff --git a/LibMatrix/StateEventTypes/Spec/CanonicalAliasEventData.cs b/LibMatrix/StateEventTypes/Spec/CanonicalAliasEventData.cs deleted file mode 100644 index 269bd6d..0000000 --- a/LibMatrix/StateEventTypes/Spec/CanonicalAliasEventData.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Text.Json.Serialization; -using LibMatrix.Helpers; -using LibMatrix.Interfaces; - -namespace LibMatrix.StateEventTypes.Spec; - -[MatrixEvent(EventName = "m.room.canonical_alias")] -public class CanonicalAliasEventData : IStateEventType { - [JsonPropertyName("alias")] - public string? Alias { get; set; } - [JsonPropertyName("alt_aliases")] - public string[]? AltAliases { get; set; } -} diff --git a/LibMatrix/StateEventTypes/Spec/GuestAccessEventData.cs b/LibMatrix/StateEventTypes/Spec/GuestAccessEventData.cs index 7ba3428..0709b86 100644 --- a/LibMatrix/StateEventTypes/Spec/GuestAccessEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/GuestAccessEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.room.guest_access")] -public class GuestAccessEventData : IStateEventType { +public class GuestAccessEventContent : EventContent { [JsonPropertyName("guest_access")] public string GuestAccess { get; set; } diff --git a/LibMatrix/StateEventTypes/Spec/HistoryVisibilityEventData.cs b/LibMatrix/StateEventTypes/Spec/HistoryVisibilityEventData.cs index deca7c8..b19dd32 100644 --- a/LibMatrix/StateEventTypes/Spec/HistoryVisibilityEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/HistoryVisibilityEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.room.history_visibility")] -public class HistoryVisibilityEventData : IStateEventType { +public class HistoryVisibilityEventContent : EventContent { [JsonPropertyName("history_visibility")] public string HistoryVisibility { get; set; } } diff --git a/LibMatrix/StateEventTypes/Spec/JoinRulesEventData.cs b/LibMatrix/StateEventTypes/Spec/JoinRulesEventData.cs index b64c1dd..8c0772f 100644 --- a/LibMatrix/StateEventTypes/Spec/JoinRulesEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/JoinRulesEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.room.join_rules")] -public class JoinRulesEventData : IStateEventType { +public class JoinRulesEventContent : EventContent { private static string Public = "public"; private static string Invite = "invite"; private static string Knock = "knock"; diff --git a/LibMatrix/StateEventTypes/Spec/PolicyRuleStateEventData.cs b/LibMatrix/StateEventTypes/Spec/PolicyRuleStateEventData.cs index 2e66bd9..539e371 100644 --- a/LibMatrix/StateEventTypes/Spec/PolicyRuleStateEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/PolicyRuleStateEventData.cs @@ -7,7 +7,7 @@ namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.policy.rule.user")] [MatrixEvent(EventName = "m.policy.rule.server")] [MatrixEvent(EventName = "org.matrix.mjolnir.rule.server")] -public class PolicyRuleStateEventData : IStateEventType { +public class PolicyRuleEventContent : EventContent { /// /// Entity this ban applies to, can use * and ? as globs. /// diff --git a/LibMatrix/StateEventTypes/Spec/PresenceStateEventData.cs b/LibMatrix/StateEventTypes/Spec/PresenceStateEventData.cs index 5167502..b897ff0 100644 --- a/LibMatrix/StateEventTypes/Spec/PresenceStateEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/PresenceStateEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.presence")] -public class PresenceStateEventData : IStateEventType { +public class PresenceEventContent : EventContent { [JsonPropertyName("presence")] public string Presence { get; set; } [JsonPropertyName("last_active_ago")] diff --git a/LibMatrix/StateEventTypes/Spec/ProfileResponseEventData.cs b/LibMatrix/StateEventTypes/Spec/ProfileResponseEventData.cs index 14449e0..9b4f1d0 100644 --- a/LibMatrix/StateEventTypes/Spec/ProfileResponseEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/ProfileResponseEventData.cs @@ -3,7 +3,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; -public class ProfileResponseEventData : IStateEventType { +public class ProfileResponseEventContent : EventContent { [JsonPropertyName("avatar_url")] public string? AvatarUrl { get; set; } diff --git a/LibMatrix/StateEventTypes/Spec/RoomAliasEventData.cs b/LibMatrix/StateEventTypes/Spec/RoomAliasEventData.cs index 3f2c39e..d3960a1 100644 --- a/LibMatrix/StateEventTypes/Spec/RoomAliasEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/RoomAliasEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.room.alias")] -public class RoomAliasEventData : IStateEventType { +public class RoomAliasEventContent : EventContent { [JsonPropertyName("aliases")] public List? Aliases { get; set; } } diff --git a/LibMatrix/StateEventTypes/Spec/RoomAvatarEventData.cs b/LibMatrix/StateEventTypes/Spec/RoomAvatarEventData.cs index f71e1fb..e2263c8 100644 --- a/LibMatrix/StateEventTypes/Spec/RoomAvatarEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/RoomAvatarEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.room.avatar")] -public class RoomAvatarEventData : IStateEventType { +public class RoomAvatarEventContent : EventContent { [JsonPropertyName("url")] public string? Url { get; set; } diff --git a/LibMatrix/StateEventTypes/Spec/RoomCreateEventData.cs b/LibMatrix/StateEventTypes/Spec/RoomCreateEventData.cs index 31f9411..22df784 100644 --- a/LibMatrix/StateEventTypes/Spec/RoomCreateEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/RoomCreateEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.room.create")] -public class RoomCreateEventData : IStateEventType { +public class RoomCreateEventContent : EventContent { [JsonPropertyName("room_version")] public string? RoomVersion { get; set; } [JsonPropertyName("creator")] diff --git a/LibMatrix/StateEventTypes/Spec/RoomEncryptionEventData.cs b/LibMatrix/StateEventTypes/Spec/RoomEncryptionEventData.cs index 9673dcc..1d5ec2c 100644 --- a/LibMatrix/StateEventTypes/Spec/RoomEncryptionEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/RoomEncryptionEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.room.encryption")] -public class RoomEncryptionEventData : IStateEventType { +public class RoomEncryptionEventContent : EventContent { [JsonPropertyName("algorithm")] public string? Algorithm { get; set; } [JsonPropertyName("rotation_period_ms")] diff --git a/LibMatrix/StateEventTypes/Spec/RoomMemberEventData.cs b/LibMatrix/StateEventTypes/Spec/RoomMemberEventData.cs index c99aa8d..a9d4710 100644 --- a/LibMatrix/StateEventTypes/Spec/RoomMemberEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/RoomMemberEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.room.member")] -public class RoomMemberEventData : IStateEventType { +public class RoomMemberEventContent : EventContent { [JsonPropertyName("reason")] public string? Reason { get; set; } diff --git a/LibMatrix/StateEventTypes/Spec/RoomMessageEventData.cs b/LibMatrix/StateEventTypes/Spec/RoomMessageEventData.cs index d13c273..a15efe8 100644 --- a/LibMatrix/StateEventTypes/Spec/RoomMessageEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/RoomMessageEventData.cs @@ -6,19 +6,12 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.room.message")] -public class RoomMessageEventData : IStateEventType { - public RoomMessageEventData() { } - - public RoomMessageEventData(string messageType, string body) { +public class RoomMessageEventContent : EventContent { + public RoomMessageEventContent(string? messageType = "m.notice", string? body = null) { MessageType = messageType; Body = body; } - public RoomMessageEventData(string body) : this() { - Body = body; - MessageType = "m.notice"; - } - [JsonPropertyName("body")] public string Body { get; set; } @@ -31,22 +24,9 @@ public class RoomMessageEventData : IStateEventType { [JsonPropertyName("format")] public string Format { get; set; } - [JsonPropertyName("m.relates_to")] - public MessageRelatesTo? RelatesTo { get; set; } - /// /// Media URI for this message, if any /// [JsonPropertyName("url")] public string? Url { get; set; } - - public class MessageRelatesTo { - [JsonPropertyName("m.in_reply_to")] - public MessageInReplyTo? InReplyTo { get; set; } - - public class MessageInReplyTo { - [JsonPropertyName("event_id")] - public string EventId { get; set; } - } - } } diff --git a/LibMatrix/StateEventTypes/Spec/RoomNameEventData.cs b/LibMatrix/StateEventTypes/Spec/RoomNameEventData.cs index e04f0dc..3002102 100644 --- a/LibMatrix/StateEventTypes/Spec/RoomNameEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/RoomNameEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.room.name")] -public class RoomNameEventData : IStateEventType { +public class RoomNameEventContent : EventContent { [JsonPropertyName("name")] public string? Name { get; set; } } diff --git a/LibMatrix/StateEventTypes/Spec/RoomPinnedEventData.cs b/LibMatrix/StateEventTypes/Spec/RoomPinnedEventData.cs index bb78aeb..16144bc 100644 --- a/LibMatrix/StateEventTypes/Spec/RoomPinnedEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/RoomPinnedEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.room.pinned_events")] -public class RoomPinnedEventData : IStateEventType { +public class RoomPinnedEventContent : EventContent { [JsonPropertyName("pinned")] public string[]? PinnedEvents { get; set; } } diff --git a/LibMatrix/StateEventTypes/Spec/RoomPowerLevelEventData.cs b/LibMatrix/StateEventTypes/Spec/RoomPowerLevelEventData.cs index b4f7d53..960c198 100644 --- a/LibMatrix/StateEventTypes/Spec/RoomPowerLevelEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/RoomPowerLevelEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.room.power_levels")] -public class RoomPowerLevelEventData : IStateEventType { +public class RoomPowerLevelEventContent : EventContent { [JsonPropertyName("ban")] public long Ban { get; set; } // = 50; diff --git a/LibMatrix/StateEventTypes/Spec/RoomTopicEventData.cs b/LibMatrix/StateEventTypes/Spec/RoomTopicEventData.cs index c3deb98..61d1a01 100644 --- a/LibMatrix/StateEventTypes/Spec/RoomTopicEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/RoomTopicEventData.cs @@ -6,7 +6,7 @@ namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.room.topic")] [MatrixEvent(EventName = "org.matrix.msc3765.topic", Legacy = true)] -public class RoomTopicEventData : IStateEventType { +public class RoomTopicEventContent : EventContent { [JsonPropertyName("topic")] public string? Topic { get; set; } } diff --git a/LibMatrix/StateEventTypes/Spec/RoomTypingEventData.cs b/LibMatrix/StateEventTypes/Spec/RoomTypingEventData.cs index 3812c46..e935cb2 100644 --- a/LibMatrix/StateEventTypes/Spec/RoomTypingEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/RoomTypingEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.typing")] -public class RoomTypingEventData : IStateEventType { +public class RoomTypingEventContent : EventContent { [JsonPropertyName("user_ids")] public string[]? UserIds { get; set; } } diff --git a/LibMatrix/StateEventTypes/Spec/ServerACLEventData.cs b/LibMatrix/StateEventTypes/Spec/ServerACLEventData.cs index d00b464..031d113 100644 --- a/LibMatrix/StateEventTypes/Spec/ServerACLEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/ServerACLEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.room.server_acl")] -public class ServerACLEventData : IStateEventType { +public class ServerACLEventContent : EventContent { [JsonPropertyName("allow")] public List Allow { get; set; } // = null!; diff --git a/LibMatrix/StateEventTypes/Spec/SpaceChildEventData.cs b/LibMatrix/StateEventTypes/Spec/SpaceChildEventData.cs index e8c6d18..80fc771 100644 --- a/LibMatrix/StateEventTypes/Spec/SpaceChildEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/SpaceChildEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.space.child")] -public class SpaceChildEventData : IStateEventType { +public class SpaceChildEventContent : EventContent { [JsonPropertyName("auto_join")] public bool? AutoJoin { get; set; } [JsonPropertyName("via")] diff --git a/LibMatrix/StateEventTypes/Spec/SpaceParentEventData.cs b/LibMatrix/StateEventTypes/Spec/SpaceParentEventData.cs index ebd083e..1bc89ab 100644 --- a/LibMatrix/StateEventTypes/Spec/SpaceParentEventData.cs +++ b/LibMatrix/StateEventTypes/Spec/SpaceParentEventData.cs @@ -5,7 +5,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.StateEventTypes.Spec; [MatrixEvent(EventName = "m.space.parent")] -public class SpaceParentEventData : IStateEventType { +public class SpaceParentEventContent : EventContent { [JsonPropertyName("via")] public string[]? Via { get; set; } diff --git a/LibMatrix/StateEventTypes/UnknownStateEventData.cs b/LibMatrix/StateEventTypes/UnknownStateEventData.cs new file mode 100644 index 0000000..59d8fd4 --- /dev/null +++ b/LibMatrix/StateEventTypes/UnknownStateEventData.cs @@ -0,0 +1,7 @@ +using LibMatrix.Interfaces; + +namespace LibMatrix.StateEventTypes; + +public class UnknownEventContent : EventContent { + +} -- cgit 1.4.1