-
Notifications
You must be signed in to change notification settings - Fork 13.5k
feat(api): migrate users.getPreferences to OpenAPI pattern #38325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
01a8720
e5674dc
4396c0a
5664ef8
9bde0f1
e21b72c
e49b8d7
3098aaa
c5fbfcc
1da067c
0b372c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@rocket.chat/meteor': patch | ||
| --- | ||
|
|
||
| Migrated users.getPreferences to OpenAPI pattern with AJV validation | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,4 +17,4 @@ | |
| "tmid", | ||
| "tshow" | ||
| ] | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .vscode settings is out of the scoop for this PR could you fix this |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -752,6 +752,21 @@ API.v1.addRoute( | |
| }, | ||
| ); | ||
|
|
||
| const UserPreferencesResponseSchema = { | ||
| type: 'object', | ||
| properties: { | ||
| preferences: { | ||
| type: 'object', | ||
| additionalProperties: true, | ||
| }, | ||
| success: { type: 'boolean', enum: [true] }, | ||
| }, | ||
| required: ['preferences', 'success'], | ||
| additionalProperties: false, | ||
| }; | ||
|
|
||
| const isUserPreferencesResponse = ajv.compile(UserPreferencesResponseSchema); | ||
|
|
||
| const usersEndpoints = API.v1 | ||
| .post( | ||
| 'users.createToken', | ||
|
|
@@ -877,26 +892,32 @@ const usersEndpoints = API.v1 | |
|
|
||
| return API.v1.success({ suggestions }); | ||
| }, | ||
| ); | ||
|
|
||
| API.v1.addRoute( | ||
| 'users.getPreferences', | ||
| { authRequired: true }, | ||
| { | ||
| async get() { | ||
| ) | ||
| .get( | ||
| 'users.getPreferences', | ||
| { | ||
| authRequired: true, | ||
| response: { | ||
| 400: validateBadRequestErrorResponse, | ||
| 401: validateUnauthorizedErrorResponse, | ||
| 200: isUserPreferencesResponse, | ||
| }, | ||
| }, | ||
| async function action() { | ||
| const user = await Users.findOneById(this.userId); | ||
|
|
||
| if (user?.settings) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Prompt for AI agents |
||
| const { preferences = {} } = user?.settings; | ||
| preferences.language = user?.language; | ||
| const { preferences = {} } = user.settings; | ||
| preferences.language = user.language; | ||
|
|
||
| return API.v1.success({ | ||
| preferences, | ||
| }); | ||
| } | ||
|
|
||
| return API.v1.failure(i18n.t('Accounts_Default_User_Preferences_not_available').toUpperCase()); | ||
| }, | ||
| }, | ||
| ); | ||
| ); | ||
|
|
||
| API.v1.addRoute( | ||
| 'users.forgotPassword', | ||
|
|
@@ -1554,7 +1575,7 @@ settings.watch<number>('Rate_Limiter_Limit_RegisterUser', (value) => { | |
| API.v1.updateRateLimiterDictionaryForRoute(userRegisterRoute, value); | ||
| }); | ||
|
|
||
| type UsersEndpoints = ExtractRoutesFromAPI<typeof usersEndpoints>; | ||
| export type UsersEndpoints = ExtractRoutesFromAPI<typeof usersEndpoints>; | ||
|
|
||
| declare module '@rocket.chat/rest-typings' { | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use minor instead of patch anymore for this project