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:
parent
651f56370a
commit
2876c7ff97
@ -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: [],
|
||||
})
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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 };
|
||||
|
Loading…
Reference in New Issue
Block a user