1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Add method to fetch the MSC3266 Room Summary of a Room (#1988)

This commit is contained in:
Michael Telatynski
2021-10-19 16:13:29 +01:00
committed by GitHub
parent 94ff0ea4cd
commit 4c39ce8c96

View File

@@ -671,6 +671,12 @@ interface IThirdPartyUser {
protocol: string;
fields: object;
}
interface IRoomSummary extends Omit<IPublicRoomsChunkRoom, "canonical_alias" | "aliases"> {
room_type?: RoomType;
membership?: string;
is_encrypted: boolean;
}
/* eslint-enable camelcase */
/**
@@ -8521,6 +8527,20 @@ export class MatrixClient extends EventEmitter {
public supportsExperimentalThreads(): boolean {
return this.clientOpts?.experimentalThreadSupport || false;
}
/**
* Fetches the summary of a room as defined by an initial version of MSC3266 and implemented in Synapse
* Proposed at https://github.com/matrix-org/matrix-doc/pull/3266
* @param {string} roomIdOrAlias The ID or alias of the room to get the summary of.
* @param {string[]?} via The list of servers which know about the room if only an ID was provided.
*/
public async getRoomSummary(roomIdOrAlias: string, via?: string[]): Promise<IRoomSummary> {
const path = utils.encodeUri("/rooms/$roomid/summary", { $roomid: roomIdOrAlias });
return this.http.authedRequest(undefined, "GET", path, { via }, null, {
qsStringifyOptions: { arrayFormat: 'repeat' },
prefix: "/_matrix/client/unstable/im.nheko.summary",
});
}
}
/**