From 03313562d21d5db9bf6a14ebbeab80e06c883d3a Mon Sep 17 00:00:00 2001 From: Rory& Date: Wed, 24 Jan 2024 02:31:56 +0100 Subject: MRU->RMU, fixes, cleanup --- .../DefaultRoomCreationTemplate.cs | 92 ++++++++++++++++++++++ .../RoomCreationTemplates/IRoomCreationTemplate.cs | 8 ++ 2 files changed, 100 insertions(+) create mode 100644 MatrixUtils.Web/Classes/RoomCreationTemplates/DefaultRoomCreationTemplate.cs create mode 100644 MatrixUtils.Web/Classes/RoomCreationTemplates/IRoomCreationTemplate.cs (limited to 'MatrixUtils.Web/Classes/RoomCreationTemplates') diff --git a/MatrixUtils.Web/Classes/RoomCreationTemplates/DefaultRoomCreationTemplate.cs b/MatrixUtils.Web/Classes/RoomCreationTemplates/DefaultRoomCreationTemplate.cs new file mode 100644 index 0000000..a627a9c --- /dev/null +++ b/MatrixUtils.Web/Classes/RoomCreationTemplates/DefaultRoomCreationTemplate.cs @@ -0,0 +1,92 @@ +using System.Text.Json.Nodes; +using LibMatrix; +using LibMatrix.EventTypes.Spec.State; +using LibMatrix.EventTypes.Spec.State.RoomInfo; +using LibMatrix.Responses; + +namespace MatrixUtils.Web.Classes.RoomCreationTemplates; + +public class DefaultRoomCreationTemplate : IRoomCreationTemplate { + public string Name => "Default"; + + public CreateRoomRequest CreateRoomRequest => + new() { + Name = "My new room", + RoomAliasName = "myroom", + InitialState = new List { + new() { + Type = "m.room.history_visibility", + TypedContent = new RoomHistoryVisibilityEventContent() { + HistoryVisibility = "world_readable" + } + }, + new() { + Type = "m.room.guest_access", + TypedContent = new RoomGuestAccessEventContent { + GuestAccess = "can_join" + } + }, + new() { + Type = "m.room.join_rules", + TypedContent = new RoomJoinRulesEventContent { + JoinRule = RoomJoinRulesEventContent.JoinRules.Public + } + }, + new() { + Type = "m.room.server_acl", + TypedContent = new RoomServerACLEventContent() { + Allow = new List() { "*" }, + Deny = new List(), + AllowIpLiterals = false + } + }, + new() { + Type = "m.room.avatar", + TypedContent = new RoomAvatarEventContent { + Url = "mxc://feline.support/UKNhEyrVsrAbYteVvZloZcFj" + } + } + }, + Visibility = "public", + PowerLevelContentOverride = new RoomPowerLevelEventContent { + UsersDefault = 0, + EventsDefault = 100, + StateDefault = 50, + Invite = 0, + Redact = 50, + Kick = 50, + Ban = 50, + NotificationsPl = new RoomPowerLevelEventContent.NotificationsPL { + Room = 50 + }, + Events = new() { + { "im.vector.modular.widgets", 50 }, + { "io.element.voice_broadcast_info", 50 }, + { "m.reaction", 100 }, + { "m.room.avatar", 50 }, + { "m.room.canonical_alias", 50 }, + { "m.room.encryption", 100 }, + { "m.room.history_visibility", 100 }, + { "m.room.name", 50 }, + { "m.room.pinned_events", 50 }, + { "m.room.power_levels", 100 }, + { "m.room.redaction", 100 }, + { "m.room.server_acl", 100 }, + { "m.room.tombstone", 100 }, + { "m.room.topic", 50 }, + { "m.space.child", 50 }, + { "org.matrix.msc3401.call", 50 }, + { "org.matrix.msc3401.call.member", 50 } + }, + Users = new() { + // { RuntimeCache.CurrentHomeserver.UserId, 100 } + //TODO: re-implement this + } + }, + CreationContent = new JsonObject { + { + "type", null + } + } + }; +} diff --git a/MatrixUtils.Web/Classes/RoomCreationTemplates/IRoomCreationTemplate.cs b/MatrixUtils.Web/Classes/RoomCreationTemplates/IRoomCreationTemplate.cs new file mode 100644 index 0000000..49aee73 --- /dev/null +++ b/MatrixUtils.Web/Classes/RoomCreationTemplates/IRoomCreationTemplate.cs @@ -0,0 +1,8 @@ +using LibMatrix.Responses; + +namespace MatrixUtils.Web.Classes.RoomCreationTemplates; + +public interface IRoomCreationTemplate { + public CreateRoomRequest CreateRoomRequest { get; } + public string Name { get; } +} -- cgit 1.5.1