From 5affd9f061e75f6575a2fe6715f9e8757cfe87e8 Mon Sep 17 00:00:00 2001 From: "Emma [it/its]@Rory&" Date: Thu, 14 Dec 2023 07:20:46 +0100 Subject: Cleanup --- .../State/RoomInfo/RoomJoinRulesEventContent.cs | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 LibMatrix.EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs (limited to 'LibMatrix.EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs') diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs new file mode 100644 index 0000000..e300b5d --- /dev/null +++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs @@ -0,0 +1,52 @@ +using System.Text.Json.Serialization; + +namespace LibMatrix.EventTypes.Spec.State; + +[MatrixEvent(EventName = "m.room.join_rules")] +public class RoomJoinRulesEventContent : TimelineEventContent { + /// + /// one of ["public", "invite", "knock", "restricted", "knock_restricted"] + /// "private" is reserved without implementation! + /// + [JsonPropertyName("join_rule")] + public string JoinRuleValue { get; set; } + + [JsonIgnore] + public required JoinRules JoinRule { + get => JoinRuleValue switch { + "public" => JoinRules.Public, + "invite" => JoinRules.Invite, + "knock" => JoinRules.Knock, + "restricted" => JoinRules.Restricted, + "knock_restricted" => JoinRules.KnockRestricted, + _ => throw new ArgumentOutOfRangeException() + }; + set => JoinRuleValue = value switch { + JoinRules.Public => "public", + JoinRules.Invite => "invite", + JoinRules.Knock => "knock", + JoinRules.Restricted => "restricted", + JoinRules.KnockRestricted => "knock_restricted", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, null) + }; + } + + [JsonPropertyName("allow")] + public List? Allow { get; set; } + + public class AllowEntry { + [JsonPropertyName("type")] + public required string Type { get; set; } + + [JsonPropertyName("room_id")] + public required string RoomId { get; set; } + } + + public enum JoinRules { + Public, + Invite, + Knock, + Restricted, + KnockRestricted + } +} -- cgit 1.4.1