From 34687b841d094aa785974ce56cd65f26ed51460f Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Sat, 2 Apr 2022 17:20:42 +0200 Subject: [PATCH 1/4] change shared to mutual --- src/client.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client.ts b/src/client.ts index 11ec7fa4d56..8d8828af291 100644 --- a/src/client.ts +++ b/src/client.ts @@ -6408,11 +6408,11 @@ export class MatrixClient extends TypedEventEmitter} Resolves to a set of rooms * @return {module:http-api.MatrixError} Rejects: with an error response. */ - public async _unstable_getSharedRooms(userId: string): Promise { // eslint-disable-line + public async _unstable_getMutualRooms(userId: string): Promise { // eslint-disable-line if (!(await this.doesServerSupportUnstableFeature("uk.half-shot.msc2666"))) { - throw Error('Server does not support shared_rooms API'); + throw Error('Server does not support mutual_rooms API'); } - const path = utils.encodeUri("/uk.half-shot.msc2666/user/shared_rooms/$userId", { + const path = utils.encodeUri("/uk.half-shot.msc2666/user/mutual_rooms/$userId", { $userId: userId, }); const res = await this.http.authedRequest<{ joined: string[] }>( From ac7c34636dbdf995ec80ce3bc6462ba71437666b Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Tue, 12 Apr 2022 10:50:23 +0200 Subject: [PATCH 2/4] revert name change --- src/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index 8d8828af291..ff0241ca8e8 100644 --- a/src/client.ts +++ b/src/client.ts @@ -6408,7 +6408,7 @@ export class MatrixClient extends TypedEventEmitter} Resolves to a set of rooms * @return {module:http-api.MatrixError} Rejects: with an error response. */ - public async _unstable_getMutualRooms(userId: string): Promise { // eslint-disable-line + public async _unstable_getSharedRooms(userId: string): Promise { // eslint-disable-line if (!(await this.doesServerSupportUnstableFeature("uk.half-shot.msc2666"))) { throw Error('Server does not support mutual_rooms API'); } From 35fa7009088cfa3d9ab9e8621f3a1081a3a41db9 Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Tue, 12 Apr 2022 11:45:58 +0200 Subject: [PATCH 3/4] use new unstable feature flag --- src/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index ff0241ca8e8..d5e3e73b8ee 100644 --- a/src/client.ts +++ b/src/client.ts @@ -6409,7 +6409,7 @@ export class MatrixClient extends TypedEventEmitter { // eslint-disable-line - if (!(await this.doesServerSupportUnstableFeature("uk.half-shot.msc2666"))) { + if (!(await this.doesServerSupportUnstableFeature("uk.half-shot.msc2666.mutual_rooms"))) { throw Error('Server does not support mutual_rooms API'); } const path = utils.encodeUri("/uk.half-shot.msc2666/user/mutual_rooms/$userId", { From 02e423bb7e9f4db1f672a32b24ed5de51e49b65a Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Tue, 12 Apr 2022 11:52:48 +0200 Subject: [PATCH 4/4] support both unstable endpoints --- src/client.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/client.ts b/src/client.ts index d5e3e73b8ee..55e87c384e2 100644 --- a/src/client.ts +++ b/src/client.ts @@ -6409,12 +6409,18 @@ export class MatrixClient extends TypedEventEmitter { // eslint-disable-line - if (!(await this.doesServerSupportUnstableFeature("uk.half-shot.msc2666.mutual_rooms"))) { + 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/mutual_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 },