From eb2cd6cb9625822c69e0adafa810f25380cce4b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ku=C3=9Fowski?= Date: Sun, 19 Oct 2025 14:00:49 +0200 Subject: [PATCH] fix: Set join rules with knowk_restricted and multiple allow condition room ids --- lib/src/room.dart | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/src/room.dart b/lib/src/room.dart index 6de83f77..da2fd10e 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -2437,18 +2437,30 @@ class Room { JoinRules joinRules, { /// For restricted rooms, the id of the room where a user needs to be member. /// Learn more at https://spec.matrix.org/latest/client-server-api/#restricted-rooms + List? allowConditionRoomIds, + @Deprecated('Use allowConditionRoomIds instead!') String? allowConditionRoomId, }) async { + if (allowConditionRoomId != null) { + allowConditionRoomIds ??= []; + allowConditionRoomIds.add(allowConditionRoomId); + } + await client.setRoomStateWithKey( id, EventTypes.RoomJoinRules, '', { - 'join_rule': joinRules.toString().replaceAll('JoinRules.', ''), - if (allowConditionRoomId != null) - 'allow': [ - {'room_id': allowConditionRoomId, 'type': 'm.room_membership'}, - ], + 'join_rule': joinRules.text, + if (allowConditionRoomIds != null && allowConditionRoomIds.isNotEmpty) + 'allow': allowConditionRoomIds + .map( + (allowConditionRoomId) => { + 'room_id': allowConditionRoomId, + 'type': 'm.room_membership', + }, + ) + .toList(), }, ); return;