Skip to content

Commit

Permalink
Merge pull request #1563 from matrix-org/t3chguy/spaces
Browse files Browse the repository at this point in the history
Initial Spaces [MSC1772] support
  • Loading branch information
t3chguy committed Feb 26, 2021
2 parents fccf08e + 9e96783 commit 14d3882
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/@types/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 23 additions & 0 deletions src/base-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: "/_matrix/client/unstable/org.matrix.msc2946",
});
};

0 comments on commit 14d3882

Please sign in to comment.