about summary refs log tree commit diff
path: root/LibMatrix.EventTypes
diff options
context:
space:
mode:
Diffstat (limited to 'LibMatrix.EventTypes')
-rw-r--r--LibMatrix.EventTypes/EventContent.cs4
-rw-r--r--LibMatrix.EventTypes/Spec/State/RoomInfo/RoomCreateEventContent.cs2
-rw-r--r--LibMatrix.EventTypes/Spec/State/RoomInfo/RoomMemberEventContent.cs61
3 files changed, 66 insertions, 1 deletions
diff --git a/LibMatrix.EventTypes/EventContent.cs b/LibMatrix.EventTypes/EventContent.cs

index d612e44..7a9f0aa 100644 --- a/LibMatrix.EventTypes/EventContent.cs +++ b/LibMatrix.EventTypes/EventContent.cs
@@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using System.Net.Http.Json; using System.Reflection; using System.Text.Json; using System.Text.Json.Nodes; @@ -17,6 +18,7 @@ public abstract class EventContent { foreach (var attr in type.GetCustomAttributes<MatrixEventAttribute>(true)) { eventTypes.Add(attr.EventName); } + return eventTypes; } } @@ -55,7 +57,7 @@ public abstract class TimelineEventContent : EventContent { // used for reactions [JsonPropertyName("key")] public string? Key { get; set; } - + [JsonExtensionData] public Dictionary<string, object>? AdditionalData { get; set; } = []; diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomCreateEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomCreateEventContent.cs
index 8519889..3dd033b 100644 --- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomCreateEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomCreateEventContent.cs
@@ -1,5 +1,7 @@ using System.Diagnostics.CodeAnalysis; +using System.Text.Json.Nodes; using System.Text.Json.Serialization; +using ArcaneLibs.Extensions; namespace LibMatrix.EventTypes.Spec.State.RoomInfo; diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomMemberEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomMemberEventContent.cs
index b034425..287754a 100644 --- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomMemberEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomMemberEventContent.cs
@@ -0,0 +1,61 @@ +using System.Text.Json; +using System.Text.Json.Nodes; +using System.Text.Json.Serialization; + +namespace LibMatrix.EventTypes.Spec.State.RoomInfo; + +[MatrixEvent(EventName = EventId)] +public class RoomMemberEventContent : EventContent { + public const string EventId = "m.room.member"; + + [JsonPropertyName("reason")] + public string? Reason { get; set; } + + [JsonPropertyName("membership")] + public required string Membership { get; set; } + + [JsonPropertyName("displayname")] + public string? DisplayName { get; set; } + + [JsonPropertyName("is_direct")] + public bool? IsDirect { get; set; } + + [JsonPropertyName("avatar_url")] + public string? AvatarUrl { get; set; } + + [JsonPropertyName("kind")] + public string? Kind { get; set; } + + [JsonPropertyName("join_authorised_via_users_server")] + public string? JoinAuthorisedViaUsersServer { get; set; } + + [JsonPropertyName("third_party_invite")] + public ThirdPartyMemberInvite? ThirdPartyInvite { get; set; } + + public class ThirdPartyMemberInvite { + [JsonPropertyName("display_name")] + public required string DisplayName { get; set; } + + [JsonPropertyName("signed")] + public required SignedThirdPartyInvite Signed { get; set; } + + public class SignedThirdPartyInvite { + [JsonPropertyName("mxid")] + public required string Mxid { get; set; } + + [JsonPropertyName("signatures")] + public required Dictionary<string, Dictionary<string, string>> Signatures { get; set; } + + [JsonPropertyName("token")] + public required string Token { get; set; } + } + } + + public static class MembershipTypes { + public const string Invite = "invite"; + public const string Join = "join"; + public const string Leave = "leave"; + public const string Ban = "ban"; + public const string Knock = "knock"; + } +} \ No newline at end of file