Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/definitions/rest/v1/users.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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 }) => {};
};
Expand Down
16 changes: 14 additions & 2 deletions app/lib/services/restApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,9 +677,21 @@ 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
Expand Down
Loading