diff --git a/app/cloud/server/functions/buildRegistrationData.js b/app/cloud/server/functions/buildRegistrationData.js index 4b7af6d4790..25baa7fac0e 100644 --- a/app/cloud/server/functions/buildRegistrationData.js +++ b/app/cloud/server/functions/buildRegistrationData.js @@ -1,6 +1,7 @@ import { settings } from '../../../settings'; import { Users } from '../../../models'; import { statistics } from '../../../statistics'; +import { LICENSE_VERSION } from '../license'; export function buildWorkspaceRegistrationData() { const stats = statistics.get(); @@ -49,6 +50,8 @@ export function buildWorkspaceRegistrationData() { deploymentMethod: stats.deploy.method, deploymentPlatform: stats.deploy.platform, version: stats.version, - setupComplete: true, + licenseVersion: LICENSE_VERSION, + enterpriseReady: true, + setupComplete: settings.get('Show_Setup_Wizard') === 'completed', }; } diff --git a/app/cloud/server/functions/getWorkspaceLicense.js b/app/cloud/server/functions/getWorkspaceLicense.js index 5fbd1ff6fdf..00916c9b93d 100644 --- a/app/cloud/server/functions/getWorkspaceLicense.js +++ b/app/cloud/server/functions/getWorkspaceLicense.js @@ -4,7 +4,7 @@ import { getWorkspaceAccessToken } from './getWorkspaceAccessToken'; import { settings } from '../../../settings'; import { Settings } from '../../../models'; import { callbacks } from '../../../callbacks'; - +import { LICENSE_VERSION } from '../license'; export function getWorkspaceLicense() { const token = getWorkspaceAccessToken(); @@ -13,10 +13,9 @@ export function getWorkspaceLicense() { return { updated: false, license: '' }; } - let licenseResult; try { - licenseResult = HTTP.get(`${ settings.get('Cloud_Workspace_Registration_Client_Uri') }/license`, { + licenseResult = HTTP.get(`${ settings.get('Cloud_Workspace_Registration_Client_Uri') }/license?version=${ LICENSE_VERSION }`, { headers: { Authorization: `Bearer ${ token }`, }, diff --git a/app/cloud/server/functions/syncWorkspace.js b/app/cloud/server/functions/syncWorkspace.js index e4c7bf85542..e116a8fcc5f 100644 --- a/app/cloud/server/functions/syncWorkspace.js +++ b/app/cloud/server/functions/syncWorkspace.js @@ -1,10 +1,9 @@ import { HTTP } from 'meteor/http'; - +import { buildWorkspaceRegistrationData } from './buildRegistrationData'; import { retrieveRegistrationStatus } from './retrieveRegistrationStatus'; import { getWorkspaceAccessToken } from './getWorkspaceAccessToken'; import { getWorkspaceLicense } from './getWorkspaceLicense'; -import { statistics } from '../../../statistics'; import { Settings } from '../../../models'; import { settings } from '../../../settings'; @@ -14,32 +13,7 @@ export function syncWorkspace(reconnectCheck = false) { return false; } - const stats = statistics.get(); - - const address = settings.get('Site_Url'); - const siteName = settings.get('Site_Name'); - const website = settings.get('Website'); - - const setupComplete = settings.get('Show_Setup_Wizard') === 'completed'; - - const { organizationType, industry, size: orgSize, country, language, serverType: workspaceType } = stats.wizard; - - const info = { - uniqueId: stats.uniqueId, - address, - siteName, - website, - organizationType, - industry, - orgSize, - country, - language, - workspaceType, - deploymentMethod: stats.deploy.method, - deploymentPlatform: stats.deploy.platform, - version: stats.version, - setupComplete, - }; + const info = buildWorkspaceRegistrationData(); const workspaceUrl = settings.get('Cloud_Workspace_Registration_Client_Uri'); diff --git a/app/cloud/server/license.js b/app/cloud/server/license.js new file mode 100644 index 00000000000..b4a98b2056a --- /dev/null +++ b/app/cloud/server/license.js @@ -0,0 +1 @@ +export const LICENSE_VERSION = 2; diff --git a/app/statistics/server/lib/statistics.js b/app/statistics/server/lib/statistics.js index 994c6e9c1e1..251cf2d146e 100644 --- a/app/statistics/server/lib/statistics.js +++ b/app/statistics/server/lib/statistics.js @@ -126,6 +126,8 @@ export const statistics = { platform: process.env.DEPLOY_PLATFORM || 'selfinstall', }; + statistics.enterpriseReady = true; + statistics.uploadsTotal = Uploads.find().count(); const [result] = Promise.await(Uploads.model.rawCollection().aggregate([{ $group: { _id: 'total', total: { $sum: '$size' } } }]).toArray()); statistics.uploadsTotalSize = result ? result.total : 0; diff --git a/ee/app/license/server/settings.js b/ee/app/license/server/settings.js index b7e8c841ff2..939e327f4c6 100644 --- a/ee/app/license/server/settings.js +++ b/ee/app/license/server/settings.js @@ -35,6 +35,10 @@ settings.get('Enterprise_License', (key, license) => { if (process.env.ROCKETCHAT_LICENSE) { Meteor.startup(() => { + if (settings.get('Enterprise_License')) { + console.warn('Rocket.Chat Enterprise: The license from your environment variable was ignored, please use only the admin setting from now on.'); + return; + } Settings.updateValueById('Enterprise_License', process.env.ROCKETCHAT_LICENSE); }); } diff --git a/ee/app/license/server/startup.js b/ee/app/license/server/startup.js index e1d75d6d193..8c9c23cf09e 100644 --- a/ee/app/license/server/startup.js +++ b/ee/app/license/server/startup.js @@ -1,5 +1,4 @@ import { settings } from '../../../../app/settings/server'; -import { getWorkspaceLicense } from '../../../../app/cloud/server'; import { callbacks } from '../../../../app/callbacks'; import { addLicense, setURL } from './license'; import './settings'; @@ -11,12 +10,6 @@ settings.get('Site_Url', (key, value) => { } }); -const { license } = getWorkspaceLicense(); - -if (license) { - addLicense(license); -} - callbacks.add('workspaceLicenseChanged', (updatedLicense) => { addLicense(updatedLicense); }); diff --git a/ee/i18n/en.i18n.json b/ee/i18n/en.i18n.json index ed956b7152c..4cd75a09ecc 100644 --- a/ee/i18n/en.i18n.json +++ b/ee/i18n/en.i18n.json @@ -9,6 +9,7 @@ "Edit_Tag": "Edit Tag", "Edit_Unit": "Edit Unit", "Enterprise_License": "Enterprise License", + "Enterprise_License_Description": "If your workspace registered and license is provided by Rocket.Chat Cloud you don't need to manually update the license here.", "Failed_to_add_monitor": "Failed to add monitor", "Invalid Canned Response": "Invalid Canned Response", "Invalid_Department": "Invalid Department", diff --git a/ee/i18n/pt-BR.i18n.json b/ee/i18n/pt-BR.i18n.json index 7a3fd7bedbb..6f1b8d857c7 100644 --- a/ee/i18n/pt-BR.i18n.json +++ b/ee/i18n/pt-BR.i18n.json @@ -5,6 +5,7 @@ "Edit_Tag": "Editar Tag", "Edit_Unit": "Editar Unidade", "Enterprise_License": "Licença Enterprise", + "Enterprise_License_Description": "Se você registrou seu workspace e a licença foi fornecida pelo Rocket.Chat Cloud você não precisa atualizar a licença manualmente aqui.", "LDAP_Default_Role_To_User": "Papel padrão para o usuário", "LDAP_Default_Role_To_User_Description": "Papel padrão par ser aplicado ao usuário, caso ele tenha algum papel do LDAP que não esteja mapeado.", "LDAP_Enable_LDAP_Roles_To_RC_Roles": "Habilitar o mapeamento de papéis do LDAP para o Rocket.Chat",