From 662dac41428370d37fc3e62ee3331a87399f7145 Mon Sep 17 00:00:00 2001 From: Krille Date: Tue, 25 Feb 2025 11:33:14 +0100 Subject: [PATCH] feat: Add parameter for allow condition for restricted rooms --- lib/src/room.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/src/room.dart b/lib/src/room.dart index 0591b77c..a466532c 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -2248,13 +2248,22 @@ class Room { } /// Changes the join rules. You should check first if the user is able to change it. - Future setJoinRules(JoinRules joinRules) async { + Future setJoinRules( + 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 + String? allowConditionRoomId, + }) async { await client.setRoomStateWithKey( id, EventTypes.RoomJoinRules, '', { 'join_rule': joinRules.toString().replaceAll('JoinRules.', ''), + if (allowConditionRoomId != null) + 'allow': [ + {'room_id': allowConditionRoomId, 'type': 'm.room_membership'}, + ], }, ); return;