From 261845f3cb7c86f7a56bb78399643606fbd81526 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Fri, 6 Sep 2024 12:36:09 +0100 Subject: [PATCH 1/8] Add MSC4133 functionality. --- src/client.ts | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/src/client.ts b/src/client.ts index 04c10ceae52..ecc2cb8098a 100644 --- a/src/client.ts +++ b/src/client.ts @@ -8806,6 +8806,128 @@ export class MatrixClient extends TypedEventEmitter> { + if (!await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133")) { + throw new Error('Server does not support extended profiles') + } + const path = await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable") ? + '/_matrix/client/v3/profile/$userId' : + '/_matrix/client/unstable/uk.tcpip.msc4133/profile/$userId'; + return this.http.authedRequest(Method.Get, utils.encodeUri(path, { userId })); + } + + /** + * Fetch a specific key from the user's *extended* profile. + * + * @see https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md + * @param userId The user ID to fetch the profile of. + * @param key The key of the property to fetch. + * @returns A set of keys to property values. + */ + public async getExtendedProfileProperty(userId: string, key: string): Promise { + if (!await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133")) { + throw new Error('Server does not support extended profiles') + } + const path = await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable") ? + '/_matrix/client/v3/profile/$userId/$key' : + '/_matrix/client/unstable/uk.tcpip.msc4133/profile/$userId/$key'; + const profile = await this.http.authedRequest(Method.Get, utils.encodeUri(path, { userId, key })) as Record; + return profile[key]; + } + + /** + * Set a property on your *extended* profile. + * + * @see https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md + * @param key The key of the property to set. + * @param value The value to set on the propety. + * @returns A set of keys to property values. + */ + public async setExtendedProfileProperty(key: string, value: unknown): Promise { + if (!await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133")) { + throw new Error('Server does not support extended profiles') + } + const path = await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable") ? + '/_matrix/client/v3/profile/$userId/$key' : + '/_matrix/client/unstable/uk.tcpip.msc4133/profile/$userId/$key'; + + const userId = this.getUserId(); + + await this.http.authedRequest(Method.Put, utils.encodeUri(path, { userId, key }), { }, { [key]: value }); + } + + /** + * Delete a property on your *extended* profile. + * + * @see https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md + * @param userId The user ID to fetch the profile of. + * @param key The key of the property to fetch. + * @returns A set of keys to property values. + */ + public async deleteExtendedProfileProperty(key: string): Promise { + if (!await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133")) { + throw new Error('Server does not support extended profiles') + } + const path = await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable") ? + '/_matrix/client/v3/profile/$userId/$key' : + '/_matrix/client/unstable/uk.tcpip.msc4133/profile/$userId/$key'; + + const userId = this.getUserId(); + + await this.http.authedRequest(Method.Delete, utils.encodeUri(path, { userId, key })); + } + + /** + * Update multiple properties on your *extended* profile. This will + * update any existing keys and leave unspecified ones intact. + * + * @see https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md + * @param userId The user ID to fetch the profile of. + * @param key The key of the property to fetch. + * @returns A set of keys to property values. + */ + public async patchExtendedProfile(profile: Record): Promise> { + if (!await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133")) { + throw new Error('Server does not support extended profiles') + } + const path = await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable") ? + '/_matrix/client/v3/profile/$userId' : + '/_matrix/client/unstable/uk.tcpip.msc4133/profile/$userId'; + + const userId = this.getUserId(); + + return this.http.authedRequest(Method.Patch, utils.encodeUri(path, { userId }), {}, profile); + } + + /** + * Set multiple properties on your *extended* profile. This will completely + * replace the existing profile, removing any unspecified keys. + * + * @see https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md + * @param userId The user ID to fetch the profile of. + * @param key The key of the property to fetch. + * @returns A set of keys to property values. + */ + public async setExtendedProfile(profile: Record): Promise> { + if (!await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133")) { + throw new Error('Server does not support extended profiles') + } + const path = await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable") ? + '/_matrix/client/v3/profile/$userId' : + '/_matrix/client/unstable/uk.tcpip.msc4133/profile/$userId'; + + const userId = this.getUserId(); + + return this.http.authedRequest(Method.Put, utils.encodeUri(path, { userId }), {}, profile); + } + /** * @returns Promise which resolves to a list of the user's threepids. * @returns Rejects: with an error response. From f78283b0f7cb9a3d7f265daae86b5f54ea499d29 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Fri, 6 Sep 2024 12:36:20 +0100 Subject: [PATCH 2/8] Add MSC4133 capability. --- src/serverCapabilities.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/serverCapabilities.ts b/src/serverCapabilities.ts index c23c9c72e92..f477ce399cd 100644 --- a/src/serverCapabilities.ts +++ b/src/serverCapabilities.ts @@ -38,6 +38,8 @@ export interface ISetDisplayNameCapability extends ICapability {} export interface ISetAvatarUrlCapability extends ICapability {} +export interface IProfileFieldsCapability extends ICapability {} + export enum RoomVersionStability { Stable = "stable", Unstable = "unstable", @@ -61,6 +63,7 @@ export interface Capabilities { "org.matrix.msc3882.get_login_token"?: IGetLoginTokenCapability; "m.set_displayname"?: ISetDisplayNameCapability; "m.set_avatar_url"?: ISetAvatarUrlCapability; + "uk.tcpip.msc4133.profile_fields"?: IProfileFieldsCapability; } type CapabilitiesResponse = { From 4437d04e7212c98bbb7efe6340e65ca7b7e62acf Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Sun, 8 Sep 2024 11:09:59 +0100 Subject: [PATCH 3/8] Tidy --- src/client.ts | 143 +++++++++++++++++++++++++------------ src/models/profile-keys.ts | 1 + 2 files changed, 98 insertions(+), 46 deletions(-) create mode 100644 src/models/profile-keys.ts diff --git a/src/client.ts b/src/client.ts index ecc2cb8098a..e010e8ea0bb 100644 --- a/src/client.ts +++ b/src/client.ts @@ -544,6 +544,8 @@ export const UNSTABLE_MSC2666_QUERY_MUTUAL_ROOMS = "uk.half-shot.msc2666.query_m export const UNSTABLE_MSC4140_DELAYED_EVENTS = "org.matrix.msc4140"; +export const UNSTABLE_MSC4133_EXTENDED_PROFILES = "uk.tcpip.msc4133"; + enum CrossSigningKeyType { MasterKey = "master_key", SelfSigningKey = "self_signing_key", @@ -8806,126 +8808,175 @@ export class MatrixClient extends TypedEventEmitter { + // Needs https://github.com/element-hq/synapse/pull/17488/files#r1749146498 to be resolved. + return true; + //return this.doesServerSupportUnstableFeature(UNSTABLE_MSC4133_EXTENDED_PROFILES); + } + /** * Fetch a user's *extended* profile, which may include additonal keys. - * + * * @see https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md * @param userId The user ID to fetch the profile of. * @returns A set of keys to property values. */ public async getExtendedProfile(userId: string): Promise> { - if (!await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133")) { - throw new Error('Server does not support extended profiles') + if (!(await this.doesServerSupportExtendedProfiles())) { + //throw new Error('Server does not support extended profiles'); } - const path = await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable") ? - '/_matrix/client/v3/profile/$userId' : - '/_matrix/client/unstable/uk.tcpip.msc4133/profile/$userId'; - return this.http.authedRequest(Method.Get, utils.encodeUri(path, { userId })); + return this.http.authedRequest( + Method.Get, + utils.encodeUri("/profile/$userId", { $userId: userId }), + undefined, + undefined, + { + prefix: (await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable")) + ? undefined + : "/_matrix/client/unstable/uk.tcpip.msc4133", + }, + ); } /** * Fetch a specific key from the user's *extended* profile. - * + * * @see https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md * @param userId The user ID to fetch the profile of. * @param key The key of the property to fetch. * @returns A set of keys to property values. */ public async getExtendedProfileProperty(userId: string, key: string): Promise { - if (!await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133")) { - throw new Error('Server does not support extended profiles') + if (!(await this.doesServerSupportExtendedProfiles())) { + //throw new Error('Server does not support extended profiles'); } - const path = await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable") ? - '/_matrix/client/v3/profile/$userId/$key' : - '/_matrix/client/unstable/uk.tcpip.msc4133/profile/$userId/$key'; - const profile = await this.http.authedRequest(Method.Get, utils.encodeUri(path, { userId, key })) as Record; + const profile = (await this.http.authedRequest( + Method.Get, + utils.encodeUri("/profile/$userId/$key", { $userId: userId, $key: key }), + undefined, + undefined, + { + prefix: (await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable")) + ? undefined + : "/_matrix/client/unstable/uk.tcpip.msc4133", + }, + )) as Record; return profile[key]; } /** * Set a property on your *extended* profile. - * + * * @see https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md * @param key The key of the property to set. * @param value The value to set on the propety. * @returns A set of keys to property values. */ public async setExtendedProfileProperty(key: string, value: unknown): Promise { - if (!await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133")) { - throw new Error('Server does not support extended profiles') + if (!(await this.doesServerSupportExtendedProfiles())) { + //throw new Error('Server does not support extended profiles'); } - const path = await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable") ? - '/_matrix/client/v3/profile/$userId/$key' : - '/_matrix/client/unstable/uk.tcpip.msc4133/profile/$userId/$key'; - const userId = this.getUserId(); - await this.http.authedRequest(Method.Put, utils.encodeUri(path, { userId, key }), { }, { [key]: value }); + await this.http.authedRequest( + Method.Put, + utils.encodeUri("/profile/$userId/$key", { $userId: userId, $key: key }), + undefined, + { [key]: value }, + { + prefix: (await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable")) + ? undefined + : "/_matrix/client/unstable/uk.tcpip.msc4133", + }, + ); } /** * Delete a property on your *extended* profile. - * + * * @see https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md * @param userId The user ID to fetch the profile of. * @param key The key of the property to fetch. * @returns A set of keys to property values. */ public async deleteExtendedProfileProperty(key: string): Promise { - if (!await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133")) { - throw new Error('Server does not support extended profiles') + if (!(await this.doesServerSupportExtendedProfiles())) { + //throw new Error('Server does not support extended profiles'); } - const path = await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable") ? - '/_matrix/client/v3/profile/$userId/$key' : - '/_matrix/client/unstable/uk.tcpip.msc4133/profile/$userId/$key'; - const userId = this.getUserId(); - await this.http.authedRequest(Method.Delete, utils.encodeUri(path, { userId, key })); + await this.http.authedRequest( + Method.Delete, + utils.encodeUri("/profile/$userId/$key", { $userId: userId, $key: key }), + undefined, + undefined, + { + prefix: (await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable")) + ? undefined + : "/_matrix/client/unstable/uk.tcpip.msc4133", + }, + ); } /** * Update multiple properties on your *extended* profile. This will * update any existing keys and leave unspecified ones intact. - * + * * @see https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md * @param userId The user ID to fetch the profile of. * @param key The key of the property to fetch. * @returns A set of keys to property values. */ public async patchExtendedProfile(profile: Record): Promise> { - if (!await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133")) { - throw new Error('Server does not support extended profiles') + if (!(await this.doesServerSupportExtendedProfiles())) { + //throw new Error('Server does not support extended profiles'); } - const path = await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable") ? - '/_matrix/client/v3/profile/$userId' : - '/_matrix/client/unstable/uk.tcpip.msc4133/profile/$userId'; - const userId = this.getUserId(); - return this.http.authedRequest(Method.Patch, utils.encodeUri(path, { userId }), {}, profile); + return this.http.authedRequest( + Method.Patch, + utils.encodeUri("/profile/$userId", { $userId: userId }), + {}, + profile, + { + prefix: (await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable")) + ? undefined + : "/_matrix/client/unstable/uk.tcpip.msc4133", + }, + ); } /** * Set multiple properties on your *extended* profile. This will completely * replace the existing profile, removing any unspecified keys. - * + * * @see https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md * @param userId The user ID to fetch the profile of. * @param key The key of the property to fetch. * @returns A set of keys to property values. */ public async setExtendedProfile(profile: Record): Promise> { - if (!await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133")) { - throw new Error('Server does not support extended profiles') + if (!(await this.doesServerSupportExtendedProfiles())) { + //throw new Error('Server does not support extended profiles'); } - const path = await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable") ? - '/_matrix/client/v3/profile/$userId' : - '/_matrix/client/unstable/uk.tcpip.msc4133/profile/$userId'; - const userId = this.getUserId(); - return this.http.authedRequest(Method.Put, utils.encodeUri(path, { userId }), {}, profile); + return this.http.authedRequest( + Method.Put, + utils.encodeUri("/profile/$userId", { $userId: userId }), + {}, + profile, + { + prefix: (await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable")) + ? undefined + : "/_matrix/client/unstable/uk.tcpip.msc4133", + }, + ); } /** diff --git a/src/models/profile-keys.ts b/src/models/profile-keys.ts new file mode 100644 index 00000000000..0dc811e8d87 --- /dev/null +++ b/src/models/profile-keys.ts @@ -0,0 +1 @@ +export const ProfileKeyMSC4175Timezone = "us.cloke.msc4175.tz"; From 62bdcc206a2fed19a143940f1280cdacad8df3c7 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Mon, 9 Sep 2024 10:12:00 +0100 Subject: [PATCH 4/8] Add tests for extended profiles. --- spec/unit/matrix-client.spec.ts | 118 ++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/spec/unit/matrix-client.spec.ts b/spec/unit/matrix-client.spec.ts index 04129ab0818..62490b95792 100644 --- a/spec/unit/matrix-client.spec.ts +++ b/spec/unit/matrix-client.spec.ts @@ -1029,6 +1029,124 @@ describe("MatrixClient", function () { }); }); + describe("extended profiles", () => { + const unstableMSC4133Prefix = `${ClientPrefix.Unstable}/uk.tcpip.msc4133`; + const userId = "@profile_user:example.org"; + + beforeEach(() => { + unstableFeatures["uk.tcpip.msc4133"] = true; + }); + + it("throws when unsupported by server", async () => { + unstableFeatures["uk.tcpip.msc4133"] = false; + const errorMessage = "Server does not support extended profiles"; + + await expect(client.doesServerSupportExtendedProfiles()).resolves.toEqual(false); + + await expect(client.getExtendedProfile(userId)).rejects.toThrow(errorMessage); + await expect(client.getExtendedProfileProperty(userId, "test_key")).rejects.toThrow(errorMessage); + await expect(client.setExtendedProfileProperty("test_key", "foo")).rejects.toThrow(errorMessage); + await expect(client.deleteExtendedProfileProperty("test_key")).rejects.toThrow(errorMessage); + await expect(client.patchExtendedProfile({ test_key: "foo" })).rejects.toThrow(errorMessage); + await expect(client.setExtendedProfile({ test_key: "foo" })).rejects.toThrow(errorMessage); + }); + + it("can fetch a extended user profile", async () => { + const testProfile = { + test_key: "foo", + }; + httpLookups = [ + { + method: "GET", + prefix: unstableMSC4133Prefix, + path: "/profile/" + encodeURIComponent(userId), + data: testProfile, + }, + ]; + await expect(client.getExtendedProfile(userId)).resolves.toEqual(testProfile); + expect(httpLookups).toHaveLength(0); + }); + + it("can fetch a property from a extended user profile", async () => { + const testProfile = { + test_key: "foo", + }; + httpLookups = [ + { + method: "GET", + prefix: unstableMSC4133Prefix, + path: "/profile/" + encodeURIComponent(userId) + "/test_key", + data: testProfile, + }, + ]; + await expect(client.getExtendedProfileProperty(userId, "test_key")).resolves.toEqual("foo"); + expect(httpLookups).toHaveLength(0); + }); + + it("can set a property in our extended profile", async () => { + httpLookups = [ + { + method: "PUT", + prefix: unstableMSC4133Prefix, + path: "/profile/" + encodeURIComponent(client.credentials.userId!) + "/test_key", + expectBody: { + test_key: "foo", + }, + }, + ]; + await expect(client.setExtendedProfileProperty("test_key", "foo")).resolves.toEqual(undefined); + expect(httpLookups).toHaveLength(0); + }); + + it("can delete a property in our extended profile", async () => { + httpLookups = [ + { + method: "DELETE", + prefix: unstableMSC4133Prefix, + path: "/profile/" + encodeURIComponent(client.credentials.userId!) + "/test_key", + }, + ]; + await expect(client.deleteExtendedProfileProperty("test_key")).resolves.toEqual(undefined); + expect(httpLookups).toHaveLength(0); + }); + + it("can patch our extended profile", async () => { + const testProfile = { + test_key: "foo", + }; + const patchedProfile = { + existing: "key", + test_key: "foo", + }; + httpLookups = [ + { + method: "PATCH", + prefix: unstableMSC4133Prefix, + path: "/profile/" + encodeURIComponent(client.credentials.userId!), + data: patchedProfile, + expectBody: testProfile, + }, + ]; + await expect(client.patchExtendedProfile(testProfile)).resolves.toEqual(patchedProfile); + }); + + it("can replace our extended profile", async () => { + const testProfile = { + test_key: "foo", + }; + httpLookups = [ + { + method: "PUT", + prefix: unstableMSC4133Prefix, + path: "/profile/" + encodeURIComponent(client.credentials.userId!), + data: testProfile, + expectBody: testProfile, + }, + ]; + await expect(client.setExtendedProfile(testProfile)).resolves.toEqual(testProfile); + }); + }); + it("should create (unstable) file trees", async () => { const userId = "@test:example.org"; const roomId = "!room:example.org"; From a6288158bdbd762667710f5ca5bd4b9177dc029e Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Mon, 9 Sep 2024 10:12:13 +0100 Subject: [PATCH 5/8] improve docs --- src/client.ts | 52 ++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/client.ts b/src/client.ts index e010e8ea0bb..985cf6b11e4 100644 --- a/src/client.ts +++ b/src/client.ts @@ -8814,9 +8814,7 @@ export class MatrixClient extends TypedEventEmitter { - // Needs https://github.com/element-hq/synapse/pull/17488/files#r1749146498 to be resolved. - return true; - //return this.doesServerSupportUnstableFeature(UNSTABLE_MSC4133_EXTENDED_PROFILES); + return this.doesServerSupportUnstableFeature(UNSTABLE_MSC4133_EXTENDED_PROFILES); } /** @@ -8825,10 +8823,13 @@ export class MatrixClient extends TypedEventEmitter> { if (!(await this.doesServerSupportExtendedProfiles())) { - //throw new Error('Server does not support extended profiles'); + throw new Error("Server does not support extended profiles"); } return this.http.authedRequest( Method.Get, @@ -8849,11 +8850,14 @@ export class MatrixClient extends TypedEventEmitter { if (!(await this.doesServerSupportExtendedProfiles())) { - //throw new Error('Server does not support extended profiles'); + throw new Error("Server does not support extended profiles"); } const profile = (await this.http.authedRequest( Method.Get, @@ -8875,11 +8879,12 @@ export class MatrixClient extends TypedEventEmitter { if (!(await this.doesServerSupportExtendedProfiles())) { - //throw new Error('Server does not support extended profiles'); + throw new Error("Server does not support extended profiles"); } const userId = this.getUserId(); @@ -8900,13 +8905,13 @@ export class MatrixClient extends TypedEventEmitter { if (!(await this.doesServerSupportExtendedProfiles())) { - //throw new Error('Server does not support extended profiles'); + throw new Error("Server does not support extended profiles"); } const userId = this.getUserId(); @@ -8925,16 +8930,17 @@ export class MatrixClient extends TypedEventEmitter): Promise> { if (!(await this.doesServerSupportExtendedProfiles())) { - //throw new Error('Server does not support extended profiles'); + throw new Error("Server does not support extended profiles"); } const userId = this.getUserId(); @@ -8956,17 +8962,17 @@ export class MatrixClient extends TypedEventEmitter): Promise> { + public async setExtendedProfile(profile: Record): Promise { if (!(await this.doesServerSupportExtendedProfiles())) { - //throw new Error('Server does not support extended profiles'); + throw new Error("Server does not support extended profiles"); } const userId = this.getUserId(); - return this.http.authedRequest( + await this.http.authedRequest( Method.Put, utils.encodeUri("/profile/$userId", { $userId: userId }), {}, From e5a240bf0f5aababa058d1be1aa81a7ddd4e49c8 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Mon, 9 Sep 2024 10:17:53 +0100 Subject: [PATCH 6/8] undefined --- spec/unit/matrix-client.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/unit/matrix-client.spec.ts b/spec/unit/matrix-client.spec.ts index 62490b95792..52d6a07778c 100644 --- a/spec/unit/matrix-client.spec.ts +++ b/spec/unit/matrix-client.spec.ts @@ -1143,7 +1143,7 @@ describe("MatrixClient", function () { expectBody: testProfile, }, ]; - await expect(client.setExtendedProfile(testProfile)).resolves.toEqual(testProfile); + await expect(client.setExtendedProfile(testProfile)).resolves.toEqual(undefined); }); }); From 5c229936f8273b5c1af6f78e4963f9f6bd965449 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Mon, 9 Sep 2024 12:19:26 +0100 Subject: [PATCH 7/8] Add a prefix function to reduce reptitiveness --- src/client.ts | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/client.ts b/src/client.ts index 985cf6b11e4..ca506caa042 100644 --- a/src/client.ts +++ b/src/client.ts @@ -8817,6 +8817,18 @@ export class MatrixClient extends TypedEventEmitter { + if (await this.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable")) { + return ClientPrefix.V3; + } + return "/_matrix/client/unstable/uk.tcpip.msc4133"; + } + /** * Fetch a user's *extended* profile, which may include additonal keys. * @@ -8837,9 +8849,7 @@ export class MatrixClient extends TypedEventEmitter; return profile[key]; @@ -8894,9 +8902,7 @@ export class MatrixClient extends TypedEventEmitter Date: Mon, 9 Sep 2024 12:22:42 +0100 Subject: [PATCH 8/8] Add a docstring --- src/models/profile-keys.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/models/profile-keys.ts b/src/models/profile-keys.ts index 0dc811e8d87..d496653cb97 100644 --- a/src/models/profile-keys.ts +++ b/src/models/profile-keys.ts @@ -1 +1,7 @@ +/** + * The timezone the user is currently in. The value of this property should + * match a timezone provided in https://www.iana.org/time-zones. + * + * @see https://github.com/matrix-org/matrix-spec-proposals/blob/clokep/profile-tz/proposals/4175-profile-field-time-zone.md + */ export const ProfileKeyMSC4175Timezone = "us.cloke.msc4175.tz";