From 0f75f2ef9c99c5d6d7a5245fab8d7d33b4334c41 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 25 Feb 2021 13:12:22 +0000 Subject: [PATCH 1/3] Add base API for Space Summary MSC2946 --- src/base-apis.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/base-apis.js b/src/base-apis.js index 07694596b11..c5a00a168d7 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -2374,3 +2374,26 @@ MatrixBaseApis.prototype.reportEvent = function(roomId, eventId, score, reason) return this._http.authedRequest(undefined, "POST", path, null, {score, reason}); }; +/** + * Fetches or paginates a summary of a space as defined by MSC2946 + * @param {string} roomId The ID of the space-room to use as the root of the summary. + * @param {number?} maxRoomsPerSpace The maximum number of rooms to return per subspace. + * @param {boolean?} autoJoinOnly Whether to only return rooms with auto_join=true. + * @param {number?} limit The maximum number of rooms to return in total. + * @param {string?} batch The opaque token to paginate a previous summary request. + * @returns {Promise} the response, with next_batch, rooms, events fields. + */ +MatrixBaseApis.prototype.getSpaceSummary = function(roomId, maxRoomsPerSpace, autoJoinOnly, limit, batch) { + const path = utils.encodeUri("/rooms/$roomId/spaces", { + $roomId: roomId, + }); + + return this._http.authedRequest(undefined, "POST", path, null, { + max_rooms_per_space: maxRoomsPerSpace, + auto_join_only: autoJoinOnly, + limit, + batch, + }, { + prefix: PREFIX_UNSTABLE, + }); +}; From bfe1987cd9331aa91b7f02d58b1ee2d7014a477e Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 26 Feb 2021 00:30:08 +0000 Subject: [PATCH 2/3] Add Spaces event types from MSC1772 --- src/@types/event.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/@types/event.ts b/src/@types/event.ts index db94f674679..adffcd560da 100644 --- a/src/@types/event.ts +++ b/src/@types/event.ts @@ -36,6 +36,10 @@ export enum EventType { */ RoomAliases = "m.room.aliases", // deprecated https://matrix.org/docs/spec/client_server/r0.6.1#historical-events + // Spaces MSC1772 + SpaceChild = "org.matrix.msc1772.space.child", + SpaceParent = "org.matrix.msc1772.space.parent", + // Room timeline events RoomRedaction = "m.room.redaction", RoomMessage = "m.room.message", From 9e967832cd51494992ce4220ae3044ac1b36c977 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 26 Feb 2021 10:37:09 +0000 Subject: [PATCH 3/3] Update space summary API unstable prefix --- src/base-apis.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base-apis.js b/src/base-apis.js index c5a00a168d7..37c3d76d63d 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -2394,6 +2394,6 @@ MatrixBaseApis.prototype.getSpaceSummary = function(roomId, maxRoomsPerSpace, au limit, batch, }, { - prefix: PREFIX_UNSTABLE, + prefix: "/_matrix/client/unstable/org.matrix.msc2946", }); };