The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/server/cron/videoConferences.ts

24 lines
956 B

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());
}