diff --git a/server/apps/microservices/src/microservices.module.ts b/server/apps/microservices/src/microservices.module.ts index 4f94f4a09d..7fa81b6dc2 100644 --- a/server/apps/microservices/src/microservices.module.ts +++ b/server/apps/microservices/src/microservices.module.ts @@ -17,6 +17,7 @@ import { GenerateChecksumProcessor } from './processors/generate-checksum.proces import { MachineLearningProcessor } from './processors/machine-learning.processor'; import { MetadataExtractionProcessor } from './processors/metadata-extraction.processor'; import { ThumbnailGeneratorProcessor } from './processors/thumbnail.processor'; +import { UserDeletionProcessor } from './processors/user-deletion.processor'; import { VideoTranscodeProcessor } from './processors/video-transcode.processor'; @Module({ @@ -38,6 +39,14 @@ import { VideoTranscodeProcessor } from './processors/video-transcode.processor' }), }), BullModule.registerQueue( + { + name: QueueNameEnum.USER_DELETION, + defaultJobOptions: { + attempts: 3, + removeOnComplete: true, + removeOnFail: false, + }, + }, { name: QueueNameEnum.THUMBNAIL_GENERATION, defaultJobOptions: { @@ -98,6 +107,7 @@ import { VideoTranscodeProcessor } from './processors/video-transcode.processor' VideoTranscodeProcessor, GenerateChecksumProcessor, MachineLearningProcessor, + UserDeletionProcessor, ], exports: [], }) diff --git a/server/apps/microservices/src/processors/user-deletion.processor.ts b/server/apps/microservices/src/processors/user-deletion.processor.ts index fa2eb0264b..37719576ec 100644 --- a/server/apps/microservices/src/processors/user-deletion.processor.ts +++ b/server/apps/microservices/src/processors/user-deletion.processor.ts @@ -26,9 +26,9 @@ export class UserDeletionProcessor { // just for extra protection here if (userUtils.isReadyForDeletion(user)) { const basePath = APP_UPLOAD_LOCATION; - const userAssetDir = join(basePath, user.id) - fs.rmSync(userAssetDir, { recursive: true, force: true }) - await this.assetRepository.delete({ userId: user.id }) + const userAssetDir = join(basePath, user.id); + fs.rmSync(userAssetDir, { recursive: true, force: true }); + await this.assetRepository.delete({ userId: user.id }); await this.userRepository.remove(user); } } diff --git a/server/libs/common/src/utils/user-utils.ts b/server/libs/common/src/utils/user-utils.ts index 7a2e04cdc1..9046ffa46b 100644 --- a/server/libs/common/src/utils/user-utils.ts +++ b/server/libs/common/src/utils/user-utils.ts @@ -7,7 +7,7 @@ function createUserUtils() { // get this number (7 days) from some configuration perhaps ? const millisecondsDeleteWait = millisecondsInDay * 7; - const millisecondsSinceDelete = new Date().getTime() - (user.deletedAt?.getTime() ?? 0); + const millisecondsSinceDelete = new Date().getTime() - (Date.parse(user.deletedAt.toString()) ?? 0); return millisecondsSinceDelete >= millisecondsDeleteWait; }; return { isReadyForDeletion };