diff --git a/apps/meteor/server/startup/migrations/index.ts b/apps/meteor/server/startup/migrations/index.ts index c6409d8e225d..5090f342d841 100644 --- a/apps/meteor/server/startup/migrations/index.ts +++ b/apps/meteor/server/startup/migrations/index.ts @@ -1,11 +1,4 @@ -import './v233'; -import './v234'; -import './v235'; -import './v236'; -import './v237'; -import './v238'; -import './v239'; -import './v240'; +import './minimumVersion'; import './v241'; import './v242'; import './v243'; diff --git a/apps/meteor/server/startup/migrations/v233.ts b/apps/meteor/server/startup/migrations/minimumVersion.ts similarity index 77% rename from apps/meteor/server/startup/migrations/v233.ts rename to apps/meteor/server/startup/migrations/minimumVersion.ts index 903a80378156..ea5e2f5bb397 100644 --- a/apps/meteor/server/startup/migrations/v233.ts +++ b/apps/meteor/server/startup/migrations/minimumVersion.ts @@ -11,7 +11,9 @@ addMigration({ '', `It seems you're trying to upgrade from an unsupported version!`, '', - 'To be able to update to version 5.0.x you need to update to version 4.x first.', + 'To be able to update to version 5.x.y you need to update to version 4.x first.', + '', + 'Read more: https://go.rocket.chat/i/how-to-upgrade', ].join('\n'), ); }, diff --git a/apps/meteor/server/startup/migrations/v234.ts b/apps/meteor/server/startup/migrations/v234.ts deleted file mode 100644 index 7db1855e989e..000000000000 --- a/apps/meteor/server/startup/migrations/v234.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Settings } from '@rocket.chat/models'; - -import { addMigration } from '../../lib/migrations'; - -addMigration({ - version: 234, - up() { - return Settings.deleteMany({ - _id: { - $in: [ - 'GoogleVision_Enable', - 'GoogleVision_ServiceAccount', - 'GoogleVision_Max_Monthly_Calls', - 'GoogleVision_Current_Month', - 'GoogleVision_Current_Month_Calls', - 'GoogleVision_Type_Document', - 'GoogleVision_Type_Faces', - 'GoogleVision_Type_Landmarks', - 'GoogleVision_Type_Labels', - 'GoogleVision_Type_Logos', - 'GoogleVision_Type_Properties', - 'GoogleVision_Type_SafeSearch', - 'GoogleVision_Block_Adult_Images', - 'GoogleVision_Type_Similar', - ], - }, - }); - }, -}); diff --git a/apps/meteor/server/startup/migrations/v235.ts b/apps/meteor/server/startup/migrations/v235.ts deleted file mode 100644 index 9344e60c37e9..000000000000 --- a/apps/meteor/server/startup/migrations/v235.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { Settings } from '@rocket.chat/models'; - -import { addMigration } from '../../lib/migrations'; -import { Subscriptions, Users } from '../../../app/models/server'; - -addMigration({ - version: 235, - async up() { - await Settings.removeById('Accounts_Default_User_Preferences_audioNotifications'); - - // delete field from subscriptions - Subscriptions.update( - { - audioNotifications: { - $exists: true, - }, - }, - { - $unset: { - audioNotifications: 1, - audioPrefOrigin: 1, - }, - }, - { multi: true }, - ); - - Subscriptions.tryDropIndex({ audioNotifications: 1 }); - - // delete field from users - Users.update( - { - 'settings.preferences.audioNotifications': { - $exists: true, - }, - }, - { - $unset: { - 'settings.preferences.audioNotifications': 1, - }, - }, - { multi: true }, - ); - }, -}); diff --git a/apps/meteor/server/startup/migrations/v236.ts b/apps/meteor/server/startup/migrations/v236.ts deleted file mode 100644 index 33955ac04d74..000000000000 --- a/apps/meteor/server/startup/migrations/v236.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Settings } from '@rocket.chat/models'; - -import { addMigration } from '../../lib/migrations'; - -addMigration({ - version: 236, - async up() { - await Settings.removeById('Canned Responses'); - await Settings.removeById('Canned_Responses'); - - await Settings.update( - { - _id: 'Canned_Responses_Enable', - }, - { - $set: { - group: 'Omnichannel', - }, - }, - { - upsert: true, - }, - ); - }, -}); diff --git a/apps/meteor/server/startup/migrations/v237.ts b/apps/meteor/server/startup/migrations/v237.ts deleted file mode 100644 index e389c714be88..000000000000 --- a/apps/meteor/server/startup/migrations/v237.ts +++ /dev/null @@ -1,117 +0,0 @@ -import { Settings } from '@rocket.chat/models'; - -import { addMigration } from '../../lib/migrations'; -import { settings } from '../../../app/settings/server'; -import { isEnterprise } from '../../../ee/app/license/server'; - -function copySettingValue(newName: string, oldName: string): void { - const value = settings.get(oldName); - if (value === undefined) { - return; - } - - Settings.update({ _id: newName }, { $set: { value } }, { upsert: true }); -} - -addMigration({ - version: 237, - async up() { - const isEE = isEnterprise(); - - // Override AD defaults with the previously configured values - copySettingValue('LDAP_AD_User_Search_Field', 'LDAP_User_Search_Field'); - copySettingValue('LDAP_AD_Username_Field', 'LDAP_Username_Field'); - - // If we're sure the server is AD, then select it - otherwise keep it as generic ldap - const useAdDefaults = settings.get('LDAP_User_Search_Field') === 'sAMAccountName'; - Settings.update( - { _id: 'LDAP_Server_Type' }, - { $set: { value: useAdDefaults ? 'ad' : '' } }, - { - upsert: true, - }, - ); - - // The setting to use the field map also determined if the user data was updated on login or not - copySettingValue('LDAP_Update_Data_On_Login', 'LDAP_Sync_User_Data'); - - let fieldMap; - try { - fieldMap = JSON.parse(settings.get('LDAP_Sync_User_Data_FieldMap') ?? ''); - } catch (_error) { - // Ignore any parsing errors; - } - - if (fieldMap) { - const newObject: Record = {}; - - for (const key in fieldMap) { - if (!fieldMap.hasOwnProperty(key)) { - continue; - } - - if (fieldMap[key] === 'name') { - Settings.update({ _id: 'LDAP_Name_Field' }, { $set: { value: key } }, { upsert: true }); - Settings.update({ _id: 'LDAP_AD_Name_Field' }, { $set: { value: key } }, { upsert: true }); - continue; - } - - if (fieldMap[key] === 'email') { - Settings.update({ _id: 'LDAP_Email_Field' }, { $set: { value: key } }, { upsert: true }); - Settings.update({ _id: 'LDAP_AD_Email_Field' }, { $set: { value: key } }, { upsert: true }); - continue; - } - - newObject[fieldMap[key]] = key; - } - - if (isEE) { - const newJson = JSON.stringify(newObject); - Settings.update({ _id: 'LDAP_CustomFieldMap' }, { $set: { value: newJson } }, { upsert: true }); - - const syncCustomFields = Object.keys(newObject).length > 0 && settings.get('LDAP_Sync_User_Data'); - Settings.update({ _id: 'LDAP_Sync_Custom_Fields' }, { $set: { value: syncCustomFields } }, { upsert: true }); - } - } - - copySettingValue('LDAP_Sync_User_Data_Roles', 'LDAP_Sync_User_Data_Groups'); - copySettingValue('LDAP_Sync_User_Data_Roles_AutoRemove', 'LDAP_Sync_User_Data_Groups_AutoRemove'); - copySettingValue('LDAP_Sync_User_Data_Roles_Filter', 'LDAP_Sync_User_Data_Groups_Filter'); - copySettingValue('LDAP_Sync_User_Data_Roles_BaseDN', 'LDAP_Sync_User_Data_Groups_BaseDN'); - copySettingValue('LDAP_Sync_User_Data_RolesMap', 'LDAP_Sync_User_Data_GroupsMap'); - copySettingValue('LDAP_Sync_User_Data_Channels', 'LDAP_Sync_User_Data_Groups_AutoChannels'); - copySettingValue('LDAP_Sync_User_Data_Channels_Admin', 'LDAP_Sync_User_Data_Groups_AutoChannels_Admin'); - copySettingValue('LDAP_Sync_User_Data_ChannelsMap', 'LDAP_Sync_User_Data_Groups_AutoChannelsMap'); - copySettingValue('LDAP_Sync_User_Data_Channels_Enforce_AutoChannels', 'LDAP_Sync_User_Data_Groups_Enforce_AutoChannels'); - - copySettingValue('LDAP_Sync_User_Data_Channels_Filter', 'LDAP_Sync_User_Data_Groups_Filter'); - copySettingValue('LDAP_Sync_User_Data_Channels_BaseDN', 'LDAP_Sync_User_Data_Groups_BaseDN'); - - await Settings.deleteMany({ - _id: { - $in: [ - 'LDAP_Sync_Now', - 'LDAP_Test_Connection', - 'LDAP_Sync_CustomFields', - 'LDAP_Sync_User_Data', - 'LDAP_Sync_User_Data_FieldMap', - 'LDAP_Enable_LDAP_Roles_To_RC_Roles', - 'LDAP_Roles_To_Rocket_Chat_Roles', - 'LDAP_Validate_Roles_For_Each_Login', - 'LDAP_Default_Role_To_User', - 'LDAP_Query_To_Get_User_Groups', - 'LDAP_Sync_User_Data_Groups', - 'LDAP_Sync_User_Data_Groups_AutoRemove', - 'LDAP_Sync_User_Data_Groups_Filter', - 'LDAP_Sync_User_Data_Groups_BaseDN', - 'LDAP_Sync_User_Data_GroupsMap', - 'LDAP_Sync_User_Data_Groups_AutoChannels', - 'LDAP_Sync_User_Data_Groups_AutoChannels_Admin', - 'LDAP_Sync_User_Data_Groups_AutoChannelsMap', - 'LDAP_Sync_User_Data_Groups_Enforce_AutoChannels', - 'LDAP_Internal_Log_Level', - ], - }, - }); - }, -}); diff --git a/apps/meteor/server/startup/migrations/v238.ts b/apps/meteor/server/startup/migrations/v238.ts deleted file mode 100644 index 1abd67a5dc01..000000000000 --- a/apps/meteor/server/startup/migrations/v238.ts +++ /dev/null @@ -1,47 +0,0 @@ -import AdmZip from 'adm-zip'; -import { AppManager } from '@rocket.chat/apps-engine/server/AppManager'; - -import { addMigration } from '../../lib/migrations'; -import { Apps } from '../../../app/apps/server'; - -function isPreCompilerRemoval(app: any): boolean { - const fileNames = Object.keys(app.compiled); - return fileNames.some((file) => file.endsWith('$ts')); -} - -function repackageAppZip(app: any): Buffer { - const zip = new AdmZip(); - - const sourceFiles: string[] = []; - - Object.entries(app.compiled).forEach(([key, value]) => { - const actualFileName = key.endsWith('$ts') ? key.replace(/\$ts$/, '.js') : key; - sourceFiles.push(actualFileName); - zip.addFile(actualFileName, Buffer.from(value as string, 'utf8')); - }); - - const zipToRead = new AdmZip(Buffer.from(app.zip, 'base64')); - - zipToRead.getEntries().forEach((entry: any) => { - if (!sourceFiles.includes(entry.entryName)) { - zip.addFile(entry.entryName, entry.getData()); - } - }); - - return zip.toBuffer(); -} - -addMigration({ - version: 238, - up() { - Apps.initialize(); - - const apps = Apps._model?.find().fetch(); - - for (const app of apps) { - const zipFile = isPreCompilerRemoval(app) ? repackageAppZip(app) : Buffer.from(app.zip, 'base64'); - Promise.await((Apps._manager as AppManager).update(zipFile, app.permissionsGranted, { loadApp: false })); - Promise.await(Apps._model?.update({ id: app.id }, { $unset: { zip: 1, compiled: 1 } })); - } - }, -}); diff --git a/apps/meteor/server/startup/migrations/v239.ts b/apps/meteor/server/startup/migrations/v239.ts deleted file mode 100644 index d491966c5bf0..000000000000 --- a/apps/meteor/server/startup/migrations/v239.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Mongo } from 'meteor/mongo'; - -import { addMigration } from '../../lib/migrations'; - -addMigration({ - version: 239, - up() { - const msg = - 'Please notice that after the next release (4.0) advanced functionalities of LDAP, SAML, and Custom Oauth will be available only in Enterprise Edition and Gold plan. Check the official announcement for more info: https://go.rocket.chat/i/authentication-changes'; - const newMsg = - 'Please note that after release 4.0 certain advanced authentication services features are available only in Enterprise Edition and Gold plan. Check the official announcement for more details: https://go.rocket.chat/i/authentication-changes'; - const Banners = new Mongo.Collection('rocketchat_banner'); - Banners.update({ 'view.blocks': { text: { text: msg } } }, { $set: { 'view.blocks': { text: { text: newMsg } } } }, { multi: true }); - }, -}); diff --git a/apps/meteor/server/startup/migrations/v240.ts b/apps/meteor/server/startup/migrations/v240.ts deleted file mode 100644 index 7cf11351ba1c..000000000000 --- a/apps/meteor/server/startup/migrations/v240.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Settings } from '@rocket.chat/models'; - -import { addMigration } from '../../lib/migrations'; - -addMigration({ - version: 240, - up() { - return Settings.removeById('Support_Cordova_App'); - }, -});