From 87d859f51ae41560f1cf45696cf90d539569aff6 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 19 Oct 2021 10:59:36 +0100 Subject: [PATCH] Add method to fetch the MSC3266 Room Summary of a Room --- src/client.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/client.ts b/src/client.ts index abade3b4e13..83a2750fd20 100644 --- a/src/client.ts +++ b/src/client.ts @@ -671,6 +671,12 @@ interface IThirdPartyUser { protocol: string; fields: object; } + +interface IRoomSummary extends Omit { + 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 { + 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", + }); + } } /**