Skip to content
Snippets Groups Projects
Unverified Commit b8d36f66 authored by Aleksander Nicacio da Silva's avatar Aleksander Nicacio da Silva Committed by GitHub
Browse files

fix: settings-related statistics not being updated according to license changes (#32237)

parent 62ac2074
No related branches found
No related tags found
No related merge requests found
---
"@rocket.chat/meteor": patch
---
**Fixed settings-related statistics not being updated according to the license.**
We've identified an issue where certain statistics were not reflecting recent license changes. This resulted in outdated information being reported for workspaces.
This change ensures that all reported statistics are current and consider the workspace license.
......@@ -70,20 +70,17 @@ export const statistics = {
const statistics = {} as IStats;
const statsPms = [];
const fetchWizardSettingValue = async <T>(settingName: string): Promise<T | undefined> => {
return ((await Settings.findOne(settingName))?.value as T | undefined) ?? undefined;
};
// Setup Wizard
const [organizationType, industry, size, country, language, serverType, registerServer] = await Promise.all([
fetchWizardSettingValue<string>('Organization_Type'),
fetchWizardSettingValue<string>('Industry'),
fetchWizardSettingValue<string>('Size'),
fetchWizardSettingValue<string>('Country'),
fetchWizardSettingValue<string>('Language'),
fetchWizardSettingValue<string>('Server_Type'),
fetchWizardSettingValue<boolean>('Register_Server'),
settings.get<string>('Organization_Type'),
settings.get<string>('Industry'),
settings.get<string>('Size'),
settings.get<string>('Country'),
settings.get<string>('Language'),
settings.get<string>('Server_Type'),
settings.get<boolean>('Register_Server'),
]);
statistics.wizard = {
organizationType,
industry,
......
import type { ISettingStatistics, ISettingStatisticsObject } from '@rocket.chat/core-typings';
import { Settings } from '@rocket.chat/models';
import { settings } from '../../../app/settings/server';
const setSettingsStatistics = async (settings: ISettingStatistics): Promise<ISettingStatisticsObject> => {
const {
......@@ -131,22 +132,16 @@ export const getSettingsStatistics = async (): Promise<ISettingStatisticsObject>
{ key: 'WebRTC_Enable_Private', alias: 'webRTCEnablePrivate' },
{ key: 'WebRTC_Enable_Direct', alias: 'webRTCEnableDirect' },
{ key: 'Canned_Responses_Enable', alias: 'cannedResponsesEnabled' },
];
] as const;
const settingsStatistics = settingsBase.reduce<ISettingStatistics>((acc, { key, alias }) => {
if (!settings.has(key)) return acc;
// Mapping only _id values
const settingsIDs = settingsBase.map((el) => el.key);
acc[alias] = settings.get(key);
const settingsStatistics = (
await Settings.findByIds(settingsIDs)
.map((el): ISettingStatistics => {
const alias = settingsBase.find((obj) => obj.key === el._id)?.alias || {};
return acc;
}, {});
if (!!alias && Object.keys(el).length) return { [String(alias)]: el.value };
return alias;
})
.filter((el: ISettingStatistics) => Object.keys(el).length) // Filter to remove all empty objects
.toArray()
).reduce((a, b) => Object.assign(a, b), {}); // Convert array to objects
const staticticObject = await setSettingsStatistics(settingsStatistics);
return staticticObject;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment