Adding Room To Space- GSoC'22 post #14

⌂ home      ⇧ one level up
Fri Aug 26, 2022 · 181 words · 1 min

I have implemented adding room to a Space.

I needed help from Tobias with it. I wanted to send m.space.child room event to a Space, but didn't know the right way to do it. Tobias suggested that I use the following function

SetRoomStateWithKeyJob* setState(const QString& evtType,
                                     const QString& stateKey,
                                     const QJsonObject& contentJson);

Here, contentJson will have the room event data.

The function call I used for removing a room from Space is

connection->callApi<SetRoomStateWithKeyJob>(spaceId, "m.space.child", roomId, QJsonObject{});

Similarly, the function call I used to add room to Space is

connection->callApi<SetRoomStateWithKeyJob>(spaceId, "m.space.child", roomId, QJsonObject{{"via", {connection->homeserver().toString()}}});

Its all well and good, except that adding room to Space doesn't work!

I asked about this to Tobias on our call. He pointed out that {connection->homeserver().toString()} should be written as QJsonObject{connection->homeserver().toString()}.

So, finally the call becomes connection->callApi<SetRoomStateWithKeyJob>(spaceId, "m.space.child", roomId, QJsonObject{{"via", QJsonArray{connection->homeserver().toString()}}});

With this, one can add or remove rooms. This feature is being added to the Child Rooms editor in Space Settings.


hire me! · blog · about · resume · github · kde invent · endeavour · email · home

🪻🌼