From f4f4686270bfee51d4d96320b606b6c6f219977a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 7 Sep 2021 12:07:18 +0100 Subject: [PATCH] tidy up code --- src/stores/SpaceStore.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/stores/SpaceStore.tsx b/src/stores/SpaceStore.tsx index edbe8327c7..ebc60b2f2c 100644 --- a/src/stores/SpaceStore.tsx +++ b/src/stores/SpaceStore.tsx @@ -371,12 +371,16 @@ export class SpaceStoreClass extends AsyncStoreWithClient { return room?.currentState.getStateEvents(EventType.SpaceParent) .map(ev => { const content = ev.getContent(); - if (!Array.isArray(content?.via)) return; - const parent = this.matrixClient.getRoom(ev.getStateKey()); - if (canonicalOnly && !content?.canonical) return; - if (parent.currentState.maySendStateEvent(EventType.SpaceChild, userId)) { - return parent; + if (Array.isArray(content?.via) && (!canonicalOnly || content?.canonical)) { + const parent = this.matrixClient.getRoom(ev.getStateKey()); + // only respect the relationship if the sender has sufficient permissions in the parent to set + // child relations, as per MSC1772. + // https://github.com/matrix-org/matrix-doc/blob/main/proposals/1772-groups-as-rooms.md#relationship-between-rooms-and-spaces + if (parent?.currentState.maySendStateEvent(EventType.SpaceChild, userId)) { + return parent; + } } + // else implicit undefined which causes this element to be filtered out }) .filter(Boolean) || []; }