Skip to content

Commit

Permalink
Change _unstable_getSharedRooms to _unstable_getMutualRooms (#2271)
Browse files Browse the repository at this point in the history
* change shared to mutual

* revert name change

* use new unstable feature flag

* support both unstable endpoints
  • Loading branch information
ShadowJonathan committed Apr 12, 2022
1 parent b58d09a commit 54661cc
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6410,12 +6410,18 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
public async _unstable_getSharedRooms(userId: string): Promise<string[]> { // eslint-disable-line
if (!(await this.doesServerSupportUnstableFeature("uk.half-shot.msc2666"))) {
throw Error('Server does not support shared_rooms API');
const sharedRoomsSupport = await this.doesServerSupportUnstableFeature("uk.half-shot.msc2666");
const mutualRoomsSupport = await this.doesServerSupportUnstableFeature("uk.half-shot.msc2666.mutual_rooms");

if (!sharedRoomsSupport && !mutualRoomsSupport) {
throw Error('Server does not support mutual_rooms API');
}
const path = utils.encodeUri("/uk.half-shot.msc2666/user/shared_rooms/$userId", {
$userId: userId,
});

const path = utils.encodeUri(
`/uk.half-shot.msc2666/user/${mutualRoomsSupport ? 'mutual_rooms' : 'shared_rooms'}/$userId`,
{ $userId: userId },
);

const res = await this.http.authedRequest<{ joined: string[] }>(
undefined, Method.Get, path, undefined, undefined,
{ prefix: PREFIX_UNSTABLE },
Expand Down

0 comments on commit 54661cc

Please sign in to comment.