Make sure user has permission to add space child

This commit is contained in:
Kelrap 2024-06-17 10:16:43 -04:00
parent 4a0ee3665f
commit aa5d09407e
2 changed files with 5 additions and 4 deletions

View file

@ -815,7 +815,6 @@ class ChatListController extends State<ChatList>
&&
selectedRoomIds
.map((id) => Matrix.of(context).client.getRoomById(id))
// .where((e) => !(e?.isPangeaClass ?? true))
.every((e) => r.canAddAsParentOf(e)),
//Pangea#
)

View file

@ -128,13 +128,15 @@ extension ChildrenAndParentsRoomExtension on Room {
return childIds;
}
// Checks if can add chat as child
// Or whether potential child space is ancestor of this
// Checks if has permissions to add child to space
// And whether potential child space is ancestor of this
bool _canAddAsParentOf(Room? child) {
if (child == null || !child.isSpace) {
return _canIAddSpaceChild(child);
}
if (id == child.id) return false;
return !child._allSpaceChildRoomIds.contains(id);
return _isRoomAdmin &&
child._isRoomAdmin &&
!child._allSpaceChildRoomIds.contains(id);
}
}