From f11fe491349854526f8d13e8b62458baeb3b23b6 Mon Sep 17 00:00:00 2001 From: "Emma [it/its]@Rory&" Date: Fri, 9 Feb 2024 16:30:49 +0100 Subject: Consistently use EventId for event types --- LibMatrix.EventTypes/Spec/State/RoomInfo/RoomAliasEventContent.cs | 2 +- .../Spec/State/RoomInfo/RoomAvatarEventContent.cs | 2 +- .../Spec/State/RoomInfo/RoomCanonicalAliasEventContent.cs | 2 +- .../Spec/State/RoomInfo/RoomCreateEventContent.cs | 2 +- .../Spec/State/RoomInfo/RoomEncryptionEventContent.cs | 7 +++++-- .../Spec/State/RoomInfo/RoomGuestAccessEventContent.cs | 5 +++-- .../Spec/State/RoomInfo/RoomHistoryVisibilityEventContent.cs | 5 +++-- .../Spec/State/RoomInfo/RoomJoinRulesEventContent.cs | 7 ++++--- .../Spec/State/RoomInfo/RoomMemberEventContent.cs | 2 +- LibMatrix.EventTypes/Spec/State/RoomInfo/RoomNameEventContent.cs | 2 +- .../Spec/State/RoomInfo/RoomPinnedEventContent.cs | 6 ++++-- .../Spec/State/RoomInfo/RoomPowerLevelEventContent.cs | 8 +++----- .../Spec/State/RoomInfo/RoomServerACLEventContent.cs | 4 ++-- LibMatrix.EventTypes/Spec/State/RoomInfo/RoomTopicEventContent.cs | 5 +++-- 14 files changed, 33 insertions(+), 26 deletions(-) (limited to 'LibMatrix.EventTypes/Spec/State/RoomInfo') diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomAliasEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomAliasEventContent.cs index 14c7cf6..4e82ac1 100644 --- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomAliasEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomAliasEventContent.cs @@ -8,4 +8,4 @@ public class RoomAliasEventContent : EventContent { [JsonPropertyName("aliases")] public List? Aliases { get; set; } -} +} \ No newline at end of file diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomAvatarEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomAvatarEventContent.cs index 62de70c..c718826 100644 --- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomAvatarEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomAvatarEventContent.cs @@ -25,4 +25,4 @@ public class RoomAvatarEventContent : EventContent { [JsonPropertyName("size")] public int? Size { get; set; } } -} +} \ No newline at end of file diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomCanonicalAliasEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomCanonicalAliasEventContent.cs index dd96016..93f13ac 100644 --- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomCanonicalAliasEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomCanonicalAliasEventContent.cs @@ -11,4 +11,4 @@ public class RoomCanonicalAliasEventContent : EventContent { [JsonPropertyName("alt_aliases")] public string[]? AltAliases { get; set; } -} +} \ No newline at end of file diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomCreateEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomCreateEventContent.cs index 02867e4..c619d0e 100644 --- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomCreateEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomCreateEventContent.cs @@ -28,4 +28,4 @@ public class RoomCreateEventContent : EventContent { [JsonPropertyName("event_id")] public string? EventId { get; set; } } -} +} \ No newline at end of file diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomEncryptionEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomEncryptionEventContent.cs index 5ddd7f3..b49abfa 100644 --- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomEncryptionEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomEncryptionEventContent.cs @@ -2,13 +2,16 @@ using System.Text.Json.Serialization; namespace LibMatrix.EventTypes.Spec.State; -[MatrixEvent(EventName = "m.room.encryption")] +[MatrixEvent(EventName = EventId)] public class RoomEncryptionEventContent : EventContent { public const string EventId = "m.room.encryption"; + [JsonPropertyName("algorithm")] public string? Algorithm { get; set; } + [JsonPropertyName("rotation_period_ms")] public ulong? RotationPeriodMs { get; set; } + [JsonPropertyName("rotation_period_msgs")] public ulong? RotationPeriodMsgs { get; set; } -} +} \ No newline at end of file diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomGuestAccessEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomGuestAccessEventContent.cs index 5e6e4d2..a7811bf 100644 --- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomGuestAccessEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomGuestAccessEventContent.cs @@ -2,9 +2,10 @@ using System.Text.Json.Serialization; namespace LibMatrix.EventTypes.Spec.State; -[MatrixEvent(EventName = "m.room.guest_access")] +[MatrixEvent(EventName = EventId)] public class RoomGuestAccessEventContent : EventContent { public const string EventId = "m.room.guest_access"; + [JsonPropertyName("guest_access")] public string GuestAccess { get; set; } @@ -13,4 +14,4 @@ public class RoomGuestAccessEventContent : EventContent { get => GuestAccess == "can_join"; set => GuestAccess = value ? "can_join" : "forbidden"; } -} +} \ No newline at end of file diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomHistoryVisibilityEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomHistoryVisibilityEventContent.cs index c523e5e..7676dad 100644 --- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomHistoryVisibilityEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomHistoryVisibilityEventContent.cs @@ -2,9 +2,10 @@ using System.Text.Json.Serialization; namespace LibMatrix.EventTypes.Spec.State; -[MatrixEvent(EventName = "m.room.history_visibility")] +[MatrixEvent(EventName = EventId)] public class RoomHistoryVisibilityEventContent : EventContent { public const string EventId = "m.room.history_visibility"; + [JsonPropertyName("history_visibility")] public string HistoryVisibility { get; set; } -} +} \ No newline at end of file diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs index 981d927..b557e47 100644 --- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs @@ -2,9 +2,10 @@ using System.Text.Json.Serialization; namespace LibMatrix.EventTypes.Spec.State; -[MatrixEvent(EventName = "m.room.join_rules")] +[MatrixEvent(EventName = EventId)] public class RoomJoinRulesEventContent : EventContent { public const string EventId = "m.room.join_rules"; + /// /// one of ["public", "invite", "knock", "restricted", "knock_restricted"] /// "private" is reserved without implementation! @@ -12,7 +13,7 @@ public class RoomJoinRulesEventContent : EventContent { /// [JsonPropertyName("join_rule")] public string JoinRuleValue { get; set; } - + [JsonIgnore] public JoinRules JoinRule { get => JoinRuleValue switch { @@ -52,4 +53,4 @@ public class RoomJoinRulesEventContent : EventContent { KnockRestricted, Private // reserved without implementation! } -} +} \ No newline at end of file diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomMemberEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomMemberEventContent.cs index 1a64f40..31983e0 100644 --- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomMemberEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomMemberEventContent.cs @@ -26,4 +26,4 @@ public class RoomMemberEventContent : EventContent { [JsonPropertyName("join_authorised_via_users_server")] public string? JoinAuthorisedViaUsersServer { get; set; } -} +} \ No newline at end of file diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomNameEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomNameEventContent.cs index 1c4513b..3ea5730 100644 --- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomNameEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomNameEventContent.cs @@ -8,4 +8,4 @@ public class RoomNameEventContent : EventContent { [JsonPropertyName("name")] public string? Name { get; set; } -} +} \ No newline at end of file diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomPinnedEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomPinnedEventContent.cs index b033d82..b4474e9 100644 --- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomPinnedEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomPinnedEventContent.cs @@ -2,8 +2,10 @@ using System.Text.Json.Serialization; namespace LibMatrix.EventTypes.Spec.State; -[MatrixEvent(EventName = "m.room.pinned_events")] +[MatrixEvent(EventName = EventId)] public class RoomPinnedEventContent : EventContent { + public const string EventId = "m.room.pinned_events"; + [JsonPropertyName("pinned")] public string[]? PinnedEvents { get; set; } -} +} \ No newline at end of file diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomPowerLevelEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomPowerLevelEventContent.cs index 325a10e..cb9ebb7 100644 --- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomPowerLevelEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomPowerLevelEventContent.cs @@ -67,13 +67,11 @@ public class RoomPowerLevelEventContent : EventContent { return Users.TryGetValue(userId, out var level) ? level : UsersDefault ?? UsersDefault ?? 0; } - public long GetEventPowerLevel(string eventType) { - return Events.TryGetValue(eventType, out var level) ? level : EventsDefault ?? EventsDefault ?? 0; - } + public long GetEventPowerLevel(string eventType) => Events.TryGetValue(eventType, out var level) ? level : EventsDefault ?? EventsDefault ?? 0; public void SetUserPowerLevel(string userId, long powerLevel) { ArgumentNullException.ThrowIfNull(userId); - Users ??= new(); + Users ??= new Dictionary(); Users[userId] = powerLevel; } -} +} \ No newline at end of file diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomServerACLEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomServerACLEventContent.cs index b720b14..be83e37 100644 --- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomServerACLEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomServerACLEventContent.cs @@ -2,7 +2,7 @@ using System.Text.Json.Serialization; namespace LibMatrix.EventTypes.Spec.State; -[MatrixEvent(EventName = "m.room.server_acl")] +[MatrixEvent(EventName = EventId)] public class RoomServerACLEventContent : EventContent { public const string EventId = "m.room.server_acl"; @@ -14,4 +14,4 @@ public class RoomServerACLEventContent : EventContent { [JsonPropertyName("allow_ip_literals")] public bool AllowIpLiterals { get; set; } // = false; -} +} \ No newline at end of file diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomTopicEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomTopicEventContent.cs index 8abb2c8..92fa75d 100644 --- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomTopicEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomTopicEventContent.cs @@ -2,10 +2,11 @@ using System.Text.Json.Serialization; namespace LibMatrix.EventTypes.Spec.State; -[MatrixEvent(EventName = "m.room.topic")] +[MatrixEvent(EventName = EventId)] [MatrixEvent(EventName = "org.matrix.msc3765.topic", Legacy = true)] public class RoomTopicEventContent : EventContent { public const string EventId = "m.room.topic"; + [JsonPropertyName("topic")] public string? Topic { get; set; } -} +} \ No newline at end of file -- cgit 1.4.1