1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-28 09:33:27 +02:00

Fix(server) Microservice didn't trigger to remove user (#1090)

This commit is contained in:
Alex 2022-12-10 18:01:29 -06:00 committed by GitHub
parent 651f56370a
commit 2876c7ff97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -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: [],
})

View File

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

View File

@ -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 };