about summary refs log tree commit diff
path: root/LibMatrix/Helpers/RoomBuilder.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-08-06 03:12:29 +0200
committerRory& <root@rory.gay>2025-08-06 03:12:29 +0200
commitfcad35734ffe635a85e27349ff09bc035f268062 (patch)
tree0245003d1245ab459de075b742fec1448bf85ee3 /LibMatrix/Helpers/RoomBuilder.cs
parentDont set own powerlevel on room creation (diff)
downloadLibMatrix-fcad35734ffe635a85e27349ff09bc035f268062.tar.xz
Handle room upgrades
Diffstat (limited to 'LibMatrix/Helpers/RoomBuilder.cs')
-rw-r--r--LibMatrix/Helpers/RoomBuilder.cs17
1 files changed, 16 insertions, 1 deletions
diff --git a/LibMatrix/Helpers/RoomBuilder.cs b/LibMatrix/Helpers/RoomBuilder.cs

index ae01d11..8843a21 100644 --- a/LibMatrix/Helpers/RoomBuilder.cs +++ b/LibMatrix/Helpers/RoomBuilder.cs
@@ -1,4 +1,5 @@ using System.Runtime.Intrinsics.X86; +using ArcaneLibs.Extensions; using LibMatrix.EventTypes.Spec.State.RoomInfo; using LibMatrix.Homeservers; using LibMatrix.Responses; @@ -34,6 +35,8 @@ public class RoomBuilder { AllowIpLiterals = false }; + public RoomEncryptionEventContent? Encryption { get; set; } + /// <summary> /// State events to be sent *before* room access is configured. Keep this small! /// </summary> @@ -47,7 +50,12 @@ public class RoomBuilder { /// <summary> /// Users to invite, with optional reason /// </summary> - public Dictionary<string, string?> Invites { get; set; } = new(); + public Dictionary<string, string?> Invites { get; set; } = []; + + /// <summary> + /// Users to ban, with optional reason + /// </summary> + public Dictionary<string, string?> Bans { get; set; } = []; public RoomPowerLevelEventContent PowerLevels { get; set; } = new() { EventsDefault = 0, @@ -184,6 +192,13 @@ public class RoomBuilder { private async Task SetAccessAsync(GenericRoom room) { if(!V12PlusRoomVersions.Contains(Version)) PowerLevels.Users![room.Homeserver.WhoAmI.UserId] = OwnPowerLevel; + else { + PowerLevels.Users!.Remove(room.Homeserver.WhoAmI.UserId); + foreach (var additionalCreator in AdditionalCreators) + { + PowerLevels.Users!.Remove(additionalCreator); + } + } await room.SendStateEventAsync(RoomPowerLevelEventContent.EventId, PowerLevels); if (!string.IsNullOrWhiteSpace(HistoryVisibility.HistoryVisibility))