snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
This commit is contained in:
18
apps/meteor/server/cron/nps.ts
Normal file
18
apps/meteor/server/cron/nps.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { NPS } from '@rocket.chat/core-services';
|
||||
import { cronJobs } from '@rocket.chat/cron';
|
||||
|
||||
import { settings } from '../settings';
|
||||
|
||||
async function runNPS(): Promise<void> {
|
||||
// if NPS is disabled close any pending scheduled survey
|
||||
const enabled = settings.get('NPS_survey_enabled');
|
||||
if (!enabled) {
|
||||
await NPS.closeOpenSurveys();
|
||||
return;
|
||||
}
|
||||
await NPS.sendResults();
|
||||
}
|
||||
|
||||
export async function npsCron(): Promise<void> {
|
||||
return cronJobs.add('NPS', '21 15 * * *', async () => runNPS());
|
||||
}
|
||||
7
apps/meteor/server/cron/oembed.ts
Normal file
7
apps/meteor/server/cron/oembed.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { cronJobs } from '@rocket.chat/cron';
|
||||
|
||||
import { executeClearOEmbedCache } from '../meteor-methods/platform/OEmbedCacheCleanup';
|
||||
|
||||
export async function oembedCron(): Promise<void> {
|
||||
return cronJobs.add('Cleanup OEmbed cache', '24 2 * * *', async () => executeClearOEmbedCache());
|
||||
}
|
||||
6
apps/meteor/server/cron/start.ts
Normal file
6
apps/meteor/server/cron/start.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { cronJobs } from '@rocket.chat/cron';
|
||||
import { MongoInternals } from 'meteor/mongo';
|
||||
|
||||
export const startCron = async () => {
|
||||
return cronJobs.start((MongoInternals.defaultRemoteCollectionDriver().mongo as any).client.db());
|
||||
};
|
||||
16
apps/meteor/server/cron/temporaryUploadsCleanup.ts
Normal file
16
apps/meteor/server/cron/temporaryUploadsCleanup.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { cronJobs } from '@rocket.chat/cron';
|
||||
import { Uploads } from '@rocket.chat/models';
|
||||
|
||||
import { FileUpload } from '../lib/media/file-upload';
|
||||
|
||||
async function temporaryUploadCleanup(): Promise<void> {
|
||||
const files = await Uploads.findExpiredTemporaryFiles({ projection: { _id: 1 } }).toArray();
|
||||
|
||||
for await (const file of files) {
|
||||
await FileUpload.getStore('Uploads').deleteById(file._id);
|
||||
}
|
||||
}
|
||||
|
||||
export async function temporaryUploadCleanupCron(): Promise<void> {
|
||||
return cronJobs.add('temporaryUploadCleanup', '31 * * * *', async () => temporaryUploadCleanup());
|
||||
}
|
||||
53
apps/meteor/server/cron/usageReport.spec.ts
Normal file
53
apps/meteor/server/cron/usageReport.spec.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { AirGappedRestriction } from '@rocket.chat/license';
|
||||
import { Statistics } from '@rocket.chat/models';
|
||||
|
||||
import { sendUsageReportAndComputeRestriction } from './usageReport';
|
||||
|
||||
jest.mock('@rocket.chat/license', () => ({
|
||||
AirGappedRestriction: {
|
||||
computeRestriction: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('@rocket.chat/models', () => ({
|
||||
Statistics: {
|
||||
findLastStatsToken: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('../lib/statistics/functions/sendUsageReport', () => ({
|
||||
sendUsageReport: () => undefined,
|
||||
}));
|
||||
|
||||
describe('sendUsageReportAndComputeRestriction', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should pass statsToken to computeRestriction when provided', async () => {
|
||||
const mockStatsToken = 'test-token';
|
||||
await sendUsageReportAndComputeRestriction(mockStatsToken);
|
||||
|
||||
expect(AirGappedRestriction.computeRestriction).toHaveBeenCalledWith(mockStatsToken);
|
||||
expect(Statistics.findLastStatsToken).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should use findLastStatsToken result when statsToken is omitted', async () => {
|
||||
const mockLastToken = 'last-token';
|
||||
(Statistics.findLastStatsToken as jest.Mock).mockResolvedValue(mockLastToken);
|
||||
|
||||
await sendUsageReportAndComputeRestriction();
|
||||
|
||||
expect(Statistics.findLastStatsToken).toHaveBeenCalled();
|
||||
expect(AirGappedRestriction.computeRestriction).toHaveBeenCalledWith(mockLastToken);
|
||||
});
|
||||
|
||||
it('should pass undefined to computeRestriction when both statsToken is omitted and findLastStatsToken returns undefined', async () => {
|
||||
(Statistics.findLastStatsToken as jest.Mock).mockResolvedValue(undefined);
|
||||
|
||||
await sendUsageReportAndComputeRestriction();
|
||||
|
||||
expect(Statistics.findLastStatsToken).toHaveBeenCalled();
|
||||
expect(AirGappedRestriction.computeRestriction).toHaveBeenCalledWith(undefined);
|
||||
});
|
||||
});
|
||||
37
apps/meteor/server/cron/usageReport.ts
Normal file
37
apps/meteor/server/cron/usageReport.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { cronJobs } from '@rocket.chat/cron';
|
||||
import { AirGappedRestriction } from '@rocket.chat/license';
|
||||
import type { Logger } from '@rocket.chat/logger';
|
||||
import { Statistics } from '@rocket.chat/models';
|
||||
|
||||
import { sendUsageReport } from '../lib/statistics/functions/sendUsageReport';
|
||||
|
||||
export const sendUsageReportAndComputeRestriction = async (statsToken?: string) => {
|
||||
// If the report failed to be sent we need to get the last existing token
|
||||
// to ensure that the restriction respects the warning period.
|
||||
// If no token is passed, the workspace will be instantly restricted.
|
||||
const token = statsToken || (await Statistics.findLastStatsToken());
|
||||
void AirGappedRestriction.computeRestriction(token);
|
||||
};
|
||||
|
||||
export const shouldReportStatistics = () => process.env.RC_DISABLE_STATISTICS_REPORTING?.toLowerCase() !== 'true';
|
||||
|
||||
export async function usageReportCron(logger: Logger): Promise<void> {
|
||||
// The actual send suppression happens inside `sendUsageReport`, but since this
|
||||
// is the entry point, we log a warning here when reporting is disabled.
|
||||
if (!shouldReportStatistics()) {
|
||||
logger.warn(
|
||||
'Statistics reporting disabled via environment variable (RC_DISABLE_STATISTICS_REPORTING). This may impact product improvements.',
|
||||
);
|
||||
}
|
||||
|
||||
const statsToken = await sendUsageReport(logger);
|
||||
await sendUsageReportAndComputeRestriction(statsToken);
|
||||
|
||||
const name = 'Generate and save statistics';
|
||||
const now = new Date();
|
||||
|
||||
return cronJobs.add(name, `12 ${now.getHours()} * * *`, async () => {
|
||||
const statsToken = await sendUsageReport(logger);
|
||||
await sendUsageReportAndComputeRestriction(statsToken);
|
||||
});
|
||||
}
|
||||
40
apps/meteor/server/cron/userDataDownloads.ts
Normal file
40
apps/meteor/server/cron/userDataDownloads.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import type { SettingValue } from '@rocket.chat/core-typings';
|
||||
import { cronJobs } from '@rocket.chat/cron';
|
||||
|
||||
import * as dataExport from '../lib/dataExport';
|
||||
import { settings } from '../settings';
|
||||
|
||||
export const userDataDownloadsCron = (): void => {
|
||||
const jobName = 'UserDataDownload';
|
||||
|
||||
const plug = async ({
|
||||
disabled,
|
||||
processingFrequency,
|
||||
}: {
|
||||
disabled: boolean;
|
||||
processingFrequency: number;
|
||||
}): Promise<(() => Promise<void>) | undefined> => {
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
await cronJobs.add(jobName, `*/${processingFrequency} * * * *`, async () => dataExport.processDataDownloads());
|
||||
|
||||
return async () => {
|
||||
await cronJobs.remove(jobName);
|
||||
};
|
||||
};
|
||||
|
||||
let unplug: (() => void) | undefined;
|
||||
|
||||
settings.watchMultiple(
|
||||
['Troubleshoot_Disable_Data_Exporter_Processor', 'UserData_ProcessingFrequency'],
|
||||
async ([disabled, processingFrequency]: SettingValue[]): Promise<void> => {
|
||||
await unplug?.();
|
||||
unplug = await plug({
|
||||
disabled: disabled === true,
|
||||
processingFrequency: typeof processingFrequency === 'number' && processingFrequency > 0 ? processingFrequency : 2,
|
||||
});
|
||||
},
|
||||
);
|
||||
};
|
||||
26
apps/meteor/server/cron/videoConferences.ts
Normal file
26
apps/meteor/server/cron/videoConferences.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { VideoConf } from '@rocket.chat/core-services';
|
||||
import type { VideoConference } from '@rocket.chat/core-typings';
|
||||
import { VideoConferenceStatus } from '@rocket.chat/core-typings';
|
||||
import { cronJobs } from '@rocket.chat/cron';
|
||||
import { VideoConference as VideoConferenceModel } from '@rocket.chat/models';
|
||||
|
||||
// 24 hours
|
||||
const VIDEO_CONFERENCE_TTL = 24 * 60 * 60 * 1000;
|
||||
|
||||
async function runVideoConferences(): Promise<void> {
|
||||
const minimum = new Date(new Date().valueOf() - VIDEO_CONFERENCE_TTL);
|
||||
|
||||
const calls = await (
|
||||
await VideoConferenceModel.findAllLongRunning(minimum)
|
||||
)
|
||||
.map(({ _id: callId }: Pick<VideoConference, '_id'>) => callId)
|
||||
.toArray();
|
||||
|
||||
await Promise.all(calls.map((callId) => VideoConf.setStatus(callId, VideoConferenceStatus.EXPIRED)));
|
||||
}
|
||||
|
||||
export async function videoConferencesCron(): Promise<void> {
|
||||
void runVideoConferences();
|
||||
|
||||
return cronJobs.add('VideoConferences', '0 */3 * * *', async () => runVideoConferences());
|
||||
}
|
||||
Reference in New Issue
Block a user