feat: Add parameter for allow condition for restricted rooms

This commit is contained in:
Krille 2025-02-25 11:33:14 +01:00
parent cebf0f6333
commit 662dac4142
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652
1 changed files with 10 additions and 1 deletions

View File

@ -2248,13 +2248,22 @@ class Room {
} }
/// Changes the join rules. You should check first if the user is able to change it. /// Changes the join rules. You should check first if the user is able to change it.
Future<void> setJoinRules(JoinRules joinRules) async { Future<void> 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( await client.setRoomStateWithKey(
id, id,
EventTypes.RoomJoinRules, EventTypes.RoomJoinRules,
'', '',
{ {
'join_rule': joinRules.toString().replaceAll('JoinRules.', ''), 'join_rule': joinRules.toString().replaceAll('JoinRules.', ''),
if (allowConditionRoomId != null)
'allow': [
{'room_id': allowConditionRoomId, 'type': 'm.room_membership'},
],
}, },
); );
return; return;