Merge pull request #2039 from famedly/krille/allow-condition-for-restricted-rooms

feat: Add parameter for allow condition for restricted rooms
This commit is contained in:
Krille-chan 2025-03-07 12:46:28 +01:00 committed by GitHub
commit 77c3dc8d2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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.
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(
id,
EventTypes.RoomJoinRules,
'',
{
'join_rule': joinRules.toString().replaceAll('JoinRules.', ''),
if (allowConditionRoomId != null)
'allow': [
{'room_id': allowConditionRoomId, 'type': 'm.room_membership'},
],
},
);
return;