From 65b5491a4729b223bf4df86ba81c1e598294851b Mon Sep 17 00:00:00 2001 From: Rory& Date: Tue, 12 Aug 2025 16:47:13 +0200 Subject: Room builder/upgrade fixes --- LibMatrix/Helpers/RoomBuilder.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'LibMatrix/Helpers/RoomBuilder.cs') diff --git a/LibMatrix/Helpers/RoomBuilder.cs b/LibMatrix/Helpers/RoomBuilder.cs index 2d8d730..601f001 100644 --- a/LibMatrix/Helpers/RoomBuilder.cs +++ b/LibMatrix/Helpers/RoomBuilder.cs @@ -35,7 +35,7 @@ public class RoomBuilder { AllowIpLiterals = false }; - public RoomEncryptionEventContent? Encryption { get; set; } + public RoomEncryptionEventContent Encryption { get; set; } = new() { }; /// /// State events to be sent *before* room access is configured. Keep this small! @@ -187,18 +187,21 @@ public class RoomBuilder { await room.Homeserver.SetRoomAliasAsync(CanonicalAlias.Alias!, room.RoomId); await room.SendStateEventAsync(RoomCanonicalAliasEventContent.EventId, CanonicalAlias); } + + if (!string.IsNullOrWhiteSpace(Encryption.Algorithm)) + await room.SendStateEventAsync(RoomEncryptionEventContent.EventId, Encryption); } private async Task SetAccessAsync(GenericRoom room) { - if(!V12PlusRoomVersions.Contains(Version)) + if (!V12PlusRoomVersions.Contains(Version)) PowerLevels.Users![room.Homeserver.WhoAmI.UserId] = OwnPowerLevel; else { PowerLevels.Users!.Remove(room.Homeserver.WhoAmI.UserId); - foreach (var additionalCreator in AdditionalCreators) - { + foreach (var additionalCreator in AdditionalCreators) { PowerLevels.Users!.Remove(additionalCreator); } } + await room.SendStateEventAsync(RoomPowerLevelEventContent.EventId, PowerLevels); if (!string.IsNullOrWhiteSpace(HistoryVisibility.HistoryVisibility)) -- cgit 1.5.1