From bb98309d6a2a9fcaf0e758d38e35c85fc6d31356 Mon Sep 17 00:00:00 2001 From: OtavioStasiak Date: Mon, 26 Jan 2026 09:50:53 -0300 Subject: [PATCH 1/3] chore: type of getAvatarSuggestion --- app/definitions/rest/v1/users.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/definitions/rest/v1/users.ts b/app/definitions/rest/v1/users.ts index fa624a5dea7..751cfbf83fb 100644 --- a/app/definitions/rest/v1/users.ts +++ b/app/definitions/rest/v1/users.ts @@ -1,4 +1,4 @@ -import { type IProfileParams } from '../../IProfile'; +import { type IAvatarSuggestion, type IProfileParams } from '../../IProfile'; import type { ITeam } from '../../ITeam'; import type { IUser, INotificationPreferences, IUserPreferences, IUserRegistered } from '../../IUser'; @@ -48,6 +48,12 @@ export type UsersEndpoints = { 'users.getUsernameSuggestion': { GET: () => { result: string }; }; + 'users.getAvatarSuggestion': { + GET: () => { + suggestions: { [service: string]: IAvatarSuggestion }; + success: boolean; + }; + }; 'users.resetAvatar': { POST: (params: { userId: string }) => {}; }; From 9932352dd0a562ee4c38f3813c947bf4b737aeb7 Mon Sep 17 00:00:00 2001 From: OtavioStasiak Date: Mon, 26 Jan 2026 09:51:43 -0300 Subject: [PATCH 2/3] chore: add getAvatarSuggestion endpoint and backward compatibility --- app/lib/services/restApi.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/lib/services/restApi.ts b/app/lib/services/restApi.ts index 95ad3f86c7e..b35a4c8bac8 100644 --- a/app/lib/services/restApi.ts +++ b/app/lib/services/restApi.ts @@ -677,9 +677,22 @@ export const getRoomRoles = ( // RC 0.65.0 sdk.get(`${roomTypeToApiType(type)}.roles`, { roomId }); -export const getAvatarSuggestion = (): Promise<{ [service: string]: IAvatarSuggestion }> => +export const getAvatarSuggestion = async (): Promise<{ [service: string]: IAvatarSuggestion }> => { + const serverVersion = reduxStore.getState().server.version; + + if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '5.4.0')) { + // RC 5.4.0 + const result = await sdk.get('users.getAvatarSuggestion'); + if (result.success && 'suggestions' in result) { + return result.suggestions; + } + return {}; + } + // RC 0.51.0 - sdk.methodCallWrapper('getAvatarSuggestion'); + return sdk.methodCallWrapper('getAvatarSuggestion'); +}; + export const resetAvatar = (userId: string) => // RC 0.55.0 From aff2c10fce8bd2ded1a8a087bda999e16868acb6 Mon Sep 17 00:00:00 2001 From: OtavioStasiak Date: Mon, 26 Jan 2026 12:58:15 +0000 Subject: [PATCH 3/3] chore: format code and fix lint issues [skip ci] --- app/lib/services/restApi.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/app/lib/services/restApi.ts b/app/lib/services/restApi.ts index b35a4c8bac8..fae53447715 100644 --- a/app/lib/services/restApi.ts +++ b/app/lib/services/restApi.ts @@ -693,7 +693,6 @@ export const getAvatarSuggestion = async (): Promise<{ [service: string]: IAvata return sdk.methodCallWrapper('getAvatarSuggestion'); }; - export const resetAvatar = (userId: string) => // RC 0.55.0 sdk.post('users.resetAvatar', { userId });