From aa5d09407ec27d58fe59a5de6996b90488bc540d Mon Sep 17 00:00:00 2001 From: Kelrap Date: Mon, 17 Jun 2024 10:16:43 -0400 Subject: [PATCH] Make sure user has permission to add space child --- lib/pages/chat_list/chat_list.dart | 1 - .../children_and_parents_extension.dart | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index 77df5b07f..58b3f9223 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -815,7 +815,6 @@ class ChatListController extends State && selectedRoomIds .map((id) => Matrix.of(context).client.getRoomById(id)) - // .where((e) => !(e?.isPangeaClass ?? true)) .every((e) => r.canAddAsParentOf(e)), //Pangea# ) diff --git a/lib/pangea/extensions/pangea_room_extension/children_and_parents_extension.dart b/lib/pangea/extensions/pangea_room_extension/children_and_parents_extension.dart index e5e7e6003..b0350853d 100644 --- a/lib/pangea/extensions/pangea_room_extension/children_and_parents_extension.dart +++ b/lib/pangea/extensions/pangea_room_extension/children_and_parents_extension.dart @@ -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); } }