mirror of
https://github.com/immich-app/immich.git
synced 2025-02-11 01:18:24 -05:00
Fix(server) Microservice didn't trigger to remove user (#1090)
This commit is contained in:
parent
651f56370a
commit
2876c7ff97
3 changed files with 14 additions and 4 deletions
|
@ -17,6 +17,7 @@ import { GenerateChecksumProcessor } from './processors/generate-checksum.proces
|
||||||
import { MachineLearningProcessor } from './processors/machine-learning.processor';
|
import { MachineLearningProcessor } from './processors/machine-learning.processor';
|
||||||
import { MetadataExtractionProcessor } from './processors/metadata-extraction.processor';
|
import { MetadataExtractionProcessor } from './processors/metadata-extraction.processor';
|
||||||
import { ThumbnailGeneratorProcessor } from './processors/thumbnail.processor';
|
import { ThumbnailGeneratorProcessor } from './processors/thumbnail.processor';
|
||||||
|
import { UserDeletionProcessor } from './processors/user-deletion.processor';
|
||||||
import { VideoTranscodeProcessor } from './processors/video-transcode.processor';
|
import { VideoTranscodeProcessor } from './processors/video-transcode.processor';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
|
@ -38,6 +39,14 @@ import { VideoTranscodeProcessor } from './processors/video-transcode.processor'
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
BullModule.registerQueue(
|
BullModule.registerQueue(
|
||||||
|
{
|
||||||
|
name: QueueNameEnum.USER_DELETION,
|
||||||
|
defaultJobOptions: {
|
||||||
|
attempts: 3,
|
||||||
|
removeOnComplete: true,
|
||||||
|
removeOnFail: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: QueueNameEnum.THUMBNAIL_GENERATION,
|
name: QueueNameEnum.THUMBNAIL_GENERATION,
|
||||||
defaultJobOptions: {
|
defaultJobOptions: {
|
||||||
|
@ -98,6 +107,7 @@ import { VideoTranscodeProcessor } from './processors/video-transcode.processor'
|
||||||
VideoTranscodeProcessor,
|
VideoTranscodeProcessor,
|
||||||
GenerateChecksumProcessor,
|
GenerateChecksumProcessor,
|
||||||
MachineLearningProcessor,
|
MachineLearningProcessor,
|
||||||
|
UserDeletionProcessor,
|
||||||
],
|
],
|
||||||
exports: [],
|
exports: [],
|
||||||
})
|
})
|
||||||
|
|
|
@ -26,9 +26,9 @@ export class UserDeletionProcessor {
|
||||||
// just for extra protection here
|
// just for extra protection here
|
||||||
if (userUtils.isReadyForDeletion(user)) {
|
if (userUtils.isReadyForDeletion(user)) {
|
||||||
const basePath = APP_UPLOAD_LOCATION;
|
const basePath = APP_UPLOAD_LOCATION;
|
||||||
const userAssetDir = join(basePath, user.id)
|
const userAssetDir = join(basePath, user.id);
|
||||||
fs.rmSync(userAssetDir, { recursive: true, force: true })
|
fs.rmSync(userAssetDir, { recursive: true, force: true });
|
||||||
await this.assetRepository.delete({ userId: user.id })
|
await this.assetRepository.delete({ userId: user.id });
|
||||||
await this.userRepository.remove(user);
|
await this.userRepository.remove(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ function createUserUtils() {
|
||||||
// get this number (7 days) from some configuration perhaps ?
|
// get this number (7 days) from some configuration perhaps ?
|
||||||
const millisecondsDeleteWait = millisecondsInDay * 7;
|
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 millisecondsSinceDelete >= millisecondsDeleteWait;
|
||||||
};
|
};
|
||||||
return { isReadyForDeletion };
|
return { isReadyForDeletion };
|
||||||
|
|
Loading…
Add table
Reference in a new issue