Skip to content

Commit

Permalink
chore: remove Troubleshoot options (#30429)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo authored Sep 18, 2023
1 parent 7c8c4b4 commit c15b1b7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 53 deletions.
26 changes: 6 additions & 20 deletions apps/meteor/app/cloud/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { cronJobs } from '@rocket.chat/cron';
import { Meteor } from 'meteor/meteor';

import { SystemLogger } from '../../../server/lib/logger/system';
import { settings } from '../../settings/server';
import { connectWorkspace } from './functions/connectWorkspace';
import { getWorkspaceAccessToken } from './functions/getWorkspaceAccessToken';
import { getWorkspaceAccessTokenWithScope } from './functions/getWorkspaceAccessTokenWithScope';
Expand All @@ -13,24 +12,6 @@ import './methods';
const licenseCronName = 'Cloud Workspace Sync';

Meteor.startup(async () => {
// run token/license sync if registered
let TroubleshootDisableWorkspaceSync: boolean;
settings.watch<boolean>('Troubleshoot_Disable_Workspace_Sync', async (value) => {
if (TroubleshootDisableWorkspaceSync === value) {
return;
}
TroubleshootDisableWorkspaceSync = value;

if (value) {
return cronJobs.remove(licenseCronName);
}

setImmediate(() => syncWorkspace());
await cronJobs.add(licenseCronName, '0 */12 * * *', async () => {
await syncWorkspace();
});
});

const { workspaceRegistered } = await retrieveRegistrationStatus();

if (process.env.REG_TOKEN && process.env.REG_TOKEN !== '' && !workspaceRegistered) {
Expand All @@ -43,9 +24,14 @@ Meteor.startup(async () => {

console.log('Successfully registered with token provided by REG_TOKEN!');
} catch (e: any) {
SystemLogger.error('An error occured registering with token.', e.message);
SystemLogger.error('An error occurred registering with token.', e.message);
}
}

setImmediate(() => syncWorkspace());
await cronJobs.add(licenseCronName, '0 */12 * * *', async () => {
await syncWorkspace();
});
});

export { getWorkspaceAccessToken, getWorkspaceAccessTokenWithScope };
4 changes: 0 additions & 4 deletions apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -5174,10 +5174,6 @@
"Troubleshoot_Disable_Presence_Broadcast_Alert": "This setting prevents all instances form sending the status changes of the users to their clients keeping all the users with their presence status from the first load!",
"Troubleshoot_Disable_Sessions_Monitor": "Disable Sessions Monitor",
"Troubleshoot_Disable_Sessions_Monitor_Alert": "This setting stops the processing of user sessions causing the statistics to stop working correctly!",
"Troubleshoot_Disable_Statistics_Generator": "Disable Statistics Generator",
"Troubleshoot_Disable_Statistics_Generator_Alert": "This setting stops the processing all statistics making the info page outdated until someone clicks on the refresh button and may cause other missing information around the system!",
"Troubleshoot_Disable_Workspace_Sync": "Disable Workspace Sync",
"Troubleshoot_Disable_Workspace_Sync_Alert": "This setting stops the sync of this server with Rocket.Chat's cloud and may cause issues with marketplace and enteprise licenses!",
"Troubleshoot_Disable_Teams_Mention": "Disable Teams mention",
"Troubleshoot_Disable_Teams_Mention_Alert": "This setting disables the teams mention feature. User's won't be able to mention a Team by name in a message and get its members notified.",
"True": "True",
Expand Down
24 changes: 3 additions & 21 deletions apps/meteor/server/cron/statistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,10 @@ async function generateStatistics(logger: Logger): Promise<void> {
}

export async function statsCron(logger: Logger): Promise<void> {
if (settings.get('Troubleshoot_Disable_Statistics_Generator')) {
return;
}

const name = 'Generate and save statistics';
await generateStatistics(logger);

let previousValue: boolean;
settings.watch<boolean>('Troubleshoot_Disable_Statistics_Generator', async (value) => {
if (value === previousValue) {
return;
}
previousValue = value;

if (value) {
await cronJobs.remove(name);
return;
}

await generateStatistics(logger);

const now = new Date();
const now = new Date();

await cronJobs.add(name, `12 ${now.getHours()} * * *`, async () => generateStatistics(logger));
});
await cronJobs.add(name, `12 ${now.getHours()} * * *`, async () => generateStatistics(logger));
}
26 changes: 18 additions & 8 deletions apps/meteor/server/settings/troubleshoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,30 @@ export const createTroubleshootSettings = () =>
type: 'boolean',
i18nDescription: 'Troubleshoot_Disable_Livechat_Activity_Monitor_Alert',
});
await this.add('Troubleshoot_Disable_Statistics_Generator', false, {
type: 'boolean',
i18nDescription: 'Troubleshoot_Disable_Statistics_Generator_Alert',
});

await this.add('Troubleshoot_Disable_Data_Exporter_Processor', false, {
type: 'boolean',
i18nDescription: 'Troubleshoot_Disable_Data_Exporter_Processor_Alert',
});
await this.add('Troubleshoot_Disable_Workspace_Sync', false, {
type: 'boolean',
i18nDescription: 'Troubleshoot_Disable_Workspace_Sync_Alert',
});
await this.add('Troubleshoot_Disable_Teams_Mention', false, {
type: 'boolean',
i18nDescription: 'Troubleshoot_Disable_Teams_Mention_Alert',
});

// TODO: remove this setting at next major (7.0.0)
await this.add('Troubleshoot_Disable_Statistics_Generator', false, {
type: 'boolean',
i18nDescription: 'Troubleshoot_Disable_Statistics_Generator_Alert',
private: true,
hidden: true,
readonly: true,
});
// TODO: remove this setting at next major (7.0.0)
await this.add('Troubleshoot_Disable_Workspace_Sync', false, {
type: 'boolean',
i18nDescription: 'Troubleshoot_Disable_Workspace_Sync_Alert',
private: true,
hidden: true,
readonly: true,
});
});

0 comments on commit c15b1b7

Please sign in to comment.