Skip to content

Commit 2e0c510

Browse files
committed
fix: Set join rules with knowk_restricted and multiple allow condition room ids
1 parent e1478a5 commit 2e0c510

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

lib/src/room.dart

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,18 +2437,30 @@ class Room {
24372437
JoinRules joinRules, {
24382438
/// For restricted rooms, the id of the room where a user needs to be member.
24392439
/// Learn more at https://spec.matrix.org/latest/client-server-api/#restricted-rooms
2440+
List<String>? allowConditionRoomIds,
2441+
@Deprecated('Use allowConditionRoomIds instead!')
24402442
String? allowConditionRoomId,
24412443
}) async {
2444+
if (allowConditionRoomId != null) {
2445+
allowConditionRoomIds ??= [];
2446+
allowConditionRoomIds.add(allowConditionRoomId);
2447+
}
2448+
24422449
await client.setRoomStateWithKey(
24432450
id,
24442451
EventTypes.RoomJoinRules,
24452452
'',
24462453
{
2447-
'join_rule': joinRules.toString().replaceAll('JoinRules.', ''),
2448-
if (allowConditionRoomId != null)
2449-
'allow': [
2450-
{'room_id': allowConditionRoomId, 'type': 'm.room_membership'},
2451-
],
2454+
'join_rule': joinRules.text,
2455+
if (allowConditionRoomIds != null)
2456+
'allow': allowConditionRoomIds
2457+
.map(
2458+
(allowConditionRoomId) => {
2459+
'room_id': allowConditionRoomId,
2460+
'type': 'm.room_membership',
2461+
},
2462+
)
2463+
.toList(),
24522464
},
24532465
);
24542466
return;

0 commit comments

Comments
 (0)