import { cronJobs } from '@rocket.chat/cron'; import { Uploads } from '@rocket.chat/models'; import { FileUpload } from '../lib/media/file-upload'; async function temporaryUploadCleanup(): Promise { 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 { return cronJobs.add('temporaryUploadCleanup', '31 * * * *', async () => temporaryUploadCleanup()); }