chore: update version check for user audit deprecation handling

This commit is contained in:
Guilherme Gazzo 2025-12-23 00:36:18 -03:00
parent 398c458490
commit 60d2019908
2 changed files with 7 additions and 6 deletions

View File

@ -235,16 +235,15 @@ const _saveUser = (session?: ClientSession) =>
return true;
};
const isBroken = shouldBreakInVersion('8.0.0');
const isBroken = shouldBreakInVersion('9.0.0');
export const saveUser = (() => {
if (isBroken) {
throw new Error('DEBUG_DISABLE_USER_AUDIT flag is deprecated and should be removed');
}
if (!process.env.DEBUG_DISABLE_USER_AUDIT) {
return wrapInSessionTransaction(_saveUser);
}
if (isBroken) {
throw new Error('DEBUG_DISABLE_USER_AUDIT flag is deprecated and should be removed');
}
const saveUserNoSession = _saveUser();
return function saveUser(userId: IUser['_id'], userData: SaveUserData, _options?: any) {
return saveUserNoSession(userId, userData);

View File

@ -1,5 +1,7 @@
import semver from 'semver';
import type { DeprecationLoggerNextPlannedVersion } from '../../app/lib/server/lib/deprecationWarningLogger';
import { Info } from '../../app/utils/rocketchat.info';
export const shouldBreakInVersion = (version: string) => semver.gte(Info.version, version);
export const shouldBreakInVersion = (version: DeprecationLoggerNextPlannedVersion) =>
Boolean(semver.gte(Info.version, version) && !process.env.TEST_MODE);