diff --git a/apps/meteor/app/lib/server/functions/cleanRoomHistory.ts b/apps/meteor/app/lib/server/functions/cleanRoomHistory.ts index 5d4774521b86..40689f3f379e 100644 --- a/apps/meteor/app/lib/server/functions/cleanRoomHistory.ts +++ b/apps/meteor/app/lib/server/functions/cleanRoomHistory.ts @@ -28,15 +28,12 @@ export const cleanRoomHistory = function ({ let fileCount = 0; Messages.findFilesByRoomIdPinnedTimestampAndUsers(rid, excludePinned, ignoreDiscussion, ts, fromUsers, ignoreThreads, { - fields: { 'file._id': 1, 'file.name': 1, 'pinned': 1 }, + fields: { 'pinned': 1, 'files': 1 }, limit, }).forEach((document: IMessage) => { - const thumbName = `thumb-${document.file?.name}`; - const uploadsStore = FileUpload.getStore('Uploads'); - uploadsStore.deleteById(document.file?._id); - uploadsStore.deleteByName(thumbName); + document.files?.forEach(file => uploadsStore.deleteById(file._id)); fileCount++; if (filesOnly) { Messages.update({ _id: document._id }, { $unset: { file: 1 }, $set: { attachments: [{ color: '#FD745E', text }] } }); diff --git a/apps/meteor/server/models/raw/Uploads.ts b/apps/meteor/server/models/raw/Uploads.ts index 6005a89b149c..17a41042cbd2 100644 --- a/apps/meteor/server/models/raw/Uploads.ts +++ b/apps/meteor/server/models/raw/Uploads.ts @@ -99,8 +99,4 @@ export class UploadsRaw extends BaseRaw implements IUploadsModel { async deleteFile(fileId: string): Promise { return this.deleteOne({ _id: fileId }); } - - async findOneByName(name: string): Promise { - return this.findOne({ name }); - } } diff --git a/packages/model-typings/src/models/IUploadsModel.ts b/packages/model-typings/src/models/IUploadsModel.ts index e4ba274b16df..8e332199a3ce 100644 --- a/packages/model-typings/src/models/IUploadsModel.ts +++ b/packages/model-typings/src/models/IUploadsModel.ts @@ -12,5 +12,4 @@ export interface IUploadsModel extends IBaseModel { deleteFile(fileId: string): Promise; - findOneByName(name: string): Promise; }