-
Notifications
You must be signed in to change notification settings - Fork 13.4k
chore: Use transaction for saveUser function #35203
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
Merged
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
223ee7f
wrap in transaction and save custom fields with updater
gabriellsh b351d4e
oops
gabriellsh a6fc69b
Pass session around
gabriellsh 3f4375d
Use updater in place of Accounts setPasswordAsync
gabriellsh 4ab2b03
pass session to avatar updates
gabriellsh 51d5c8f
fix ts
gabriellsh c9de44b
fix unit
gabriellsh 840a8ca
fix session passed to deferred operation
gabriellsh 133152c
Move return clause in wrapInSessionTransaction
gabriellsh 5800b2e
fix optional chaining and typo
gabriellsh 902819f
Inline type in updateGroupDMsName
gabriellsh 0ae5e05
accept only session in models methods options
gabriellsh 3a462e0
Merge branch 'develop' into chore/updateUserTransaction
gabriellsh 869f81e
helper for once session ended
gabriellsh 3e8aafa
attach customfield side effect to event
gabriellsh a95661c
session in setUserAvatar
gabriellsh a59e1f0
session in setRealName
gabriellsh 509a155
sideEffects after transaction in saveUserIdentity
gabriellsh 0b860e4
session in setUsername
gabriellsh 3c0015d
session in setEmail
gabriellsh ea103bd
session in setStatusText
gabriellsh ab64c3f
sideEffects after transaction commited in saveUser
gabriellsh 05b1e6d
Update users model
gabriellsh 152bfe4
Update Subscriptions model
gabriellsh cc44839
update BaseUploadModel
gabriellsh 388d838
Update BaseRaw
gabriellsh 59bf8aa
pass session to fileStore
gabriellsh ab6d7cb
Fix use of expired transaction
gabriellsh b455092
fix setUserAvatar
gabriellsh 9d5fc45
Removed unused session from models
gabriellsh b420f80
Change module declaration
gabriellsh ef5d8c8
fix unit
gabriellsh a39484e
Merge branch 'develop' into chore/updateUserTransaction
gabriellsh cb7a812
Merge branch 'develop' into chore/updateUserTransaction
gabriellsh 7104d0f
transaction success proxy event
gabriellsh 8ad3063
Log errored side effects
gabriellsh e07b09b
wrap transaction error
gabriellsh 979e9cf
Add flag to disable transaction
gabriellsh 69d9a65
Merge branch 'develop' into chore/updateUserTransaction
gabriellsh ee6793a
Merge branch 'develop' into chore/updateUserTransaction
gabriellsh 8238e17
Merge branch 'develop' into chore/updateUserTransaction
gabriellsh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,21 @@ | ||
| import type { IUser } from '@rocket.chat/core-typings'; | ||
| import type { Updater } from '@rocket.chat/models'; | ||
| import type { ClientSession } from 'mongodb'; | ||
|
|
||
| import { saveCustomFieldsWithoutValidation } from './saveCustomFieldsWithoutValidation'; | ||
| import { validateCustomFields } from './validateCustomFields'; | ||
| import { trim } from '../../../../lib/utils/stringUtils'; | ||
| import { settings } from '../../../settings/server'; | ||
|
|
||
| export const saveCustomFields = async function (userId: string, formData: Record<string, any>): Promise<void> { | ||
| export const saveCustomFields = async function ( | ||
| userId: string, | ||
| formData: Record<string, any>, | ||
| options?: { _updater?: Updater<IUser>; session?: ClientSession }, | ||
| ): Promise<void> { | ||
| if (trim(settings.get('Accounts_CustomFields')).length === 0) { | ||
| return; | ||
| } | ||
|
|
||
| validateCustomFields(formData); | ||
| return saveCustomFieldsWithoutValidation(userId, formData); | ||
| return saveCustomFieldsWithoutValidation(userId, formData, options); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.