fix: Set join rules with knowk_restricted and multiple allow condition room ids
This commit is contained in:
parent
c3f89d9bcf
commit
eb2cd6cb96
|
|
@ -2437,18 +2437,30 @@ class Room {
|
||||||
JoinRules joinRules, {
|
JoinRules joinRules, {
|
||||||
/// For restricted rooms, the id of the room where a user needs to be member.
|
/// 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
|
/// Learn more at https://spec.matrix.org/latest/client-server-api/#restricted-rooms
|
||||||
|
List<String>? allowConditionRoomIds,
|
||||||
|
@Deprecated('Use allowConditionRoomIds instead!')
|
||||||
String? allowConditionRoomId,
|
String? allowConditionRoomId,
|
||||||
}) async {
|
}) async {
|
||||||
|
if (allowConditionRoomId != null) {
|
||||||
|
allowConditionRoomIds ??= [];
|
||||||
|
allowConditionRoomIds.add(allowConditionRoomId);
|
||||||
|
}
|
||||||
|
|
||||||
await client.setRoomStateWithKey(
|
await client.setRoomStateWithKey(
|
||||||
id,
|
id,
|
||||||
EventTypes.RoomJoinRules,
|
EventTypes.RoomJoinRules,
|
||||||
'',
|
'',
|
||||||
{
|
{
|
||||||
'join_rule': joinRules.toString().replaceAll('JoinRules.', ''),
|
'join_rule': joinRules.text,
|
||||||
if (allowConditionRoomId != null)
|
if (allowConditionRoomIds != null && allowConditionRoomIds.isNotEmpty)
|
||||||
'allow': [
|
'allow': allowConditionRoomIds
|
||||||
{'room_id': allowConditionRoomId, 'type': 'm.room_membership'},
|
.map(
|
||||||
],
|
(allowConditionRoomId) => {
|
||||||
|
'room_id': allowConditionRoomId,
|
||||||
|
'type': 'm.room_membership',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue