account for matrix space child permissions
This commit is contained in:
parent
9ed7507353
commit
5ce1d556b6
3 changed files with 18 additions and 13 deletions
|
|
@ -131,7 +131,8 @@ extension ChildrenAndParentsRoomExtension on Room {
|
|||
spaceMode = child?.isSpace ?? spaceMode;
|
||||
|
||||
// get the bool for adding chats to spaces
|
||||
final bool canAddChild = child?.isRoomAdmin ?? true;
|
||||
final bool canAddChild =
|
||||
(child?.isRoomAdmin ?? true) && canSendEvent(EventTypes.SpaceChild);
|
||||
if (!spaceMode) return canAddChild;
|
||||
|
||||
// if adding space to a space, check if the child is an ancestor
|
||||
|
|
|
|||
|
|
@ -67,7 +67,9 @@ extension AnalyticsRoomExtension on Room {
|
|||
return Future.value();
|
||||
}
|
||||
|
||||
if (!canSendEvent(EventTypes.SpaceChild)) return;
|
||||
if (spaceChildren.any((sc) => sc.roomId == analyticsRoom.id)) return;
|
||||
|
||||
try {
|
||||
await setSpaceChild(analyticsRoom.id);
|
||||
} catch (err) {
|
||||
|
|
|
|||
|
|
@ -76,18 +76,6 @@ class AddToSpaceState extends State<AddToSpaceToggles> {
|
|||
)
|
||||
: null;
|
||||
|
||||
if (widget.activeSpaceId != null) {
|
||||
final activeSpace =
|
||||
Matrix.of(context).client.getRoomById(widget.activeSpaceId!);
|
||||
if (activeSpace != null) {
|
||||
parent = activeSpace;
|
||||
} else {
|
||||
ErrorHandler.logError(
|
||||
e: Exception('activeSpaceId ${widget.activeSpaceId} not found'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//sort possibleParents
|
||||
//if possibleParent in parents, put first
|
||||
//use sort but use any instead of contains because contains uses == and we want to compare by id
|
||||
|
|
@ -102,6 +90,20 @@ class AddToSpaceState extends State<AddToSpaceToggles> {
|
|||
});
|
||||
|
||||
isOpen = widget.startOpen;
|
||||
|
||||
if (widget.activeSpaceId != null) {
|
||||
final activeSpace =
|
||||
Matrix.of(context).client.getRoomById(widget.activeSpaceId!);
|
||||
if (activeSpace == null) {
|
||||
ErrorHandler.logError(
|
||||
e: Exception('activeSpaceId ${widget.activeSpaceId} not found'),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (activeSpace.canSendEvent(EventTypes.SpaceChild)) {
|
||||
parent = activeSpace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _addSingleSpace(String roomToAddId, Room newParent) async {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue