diff --git a/server/apps/immich/src/api-v1/asset/asset.core.ts b/server/apps/immich/src/api-v1/asset/asset.core.ts index f0a819f2f5..8d3992d389 100644 --- a/server/apps/immich/src/api-v1/asset/asset.core.ts +++ b/server/apps/immich/src/api-v1/asset/asset.core.ts @@ -41,7 +41,7 @@ export class AssetCore { faces: [], }); - await this.jobRepository.queue({ name: JobName.ASSET_UPLOADED, data: { asset, fileName: file.originalName } }); + await this.jobRepository.queue({ name: JobName.ASSET_UPLOADED, data: { asset } }); return asset; } diff --git a/server/apps/immich/src/api-v1/asset/asset.service.spec.ts b/server/apps/immich/src/api-v1/asset/asset.service.spec.ts index 12bfbc7007..80d5cc91da 100644 --- a/server/apps/immich/src/api-v1/asset/asset.service.spec.ts +++ b/server/apps/immich/src/api-v1/asset/asset.service.spec.ts @@ -328,18 +328,8 @@ describe('AssetService', () => { }); expect(jobMock.queue.mock.calls).toEqual([ - [ - { - name: JobName.ASSET_UPLOADED, - data: { asset: assetEntityStub.livePhotoMotionAsset, fileName: 'asset_1.mp4' }, - }, - ], - [ - { - name: JobName.ASSET_UPLOADED, - data: { asset: assetEntityStub.livePhotoStillAsset, fileName: 'asset_1.jpeg' }, - }, - ], + [{ name: JobName.ASSET_UPLOADED, data: { asset: assetEntityStub.livePhotoMotionAsset } }], + [{ name: JobName.ASSET_UPLOADED, data: { asset: assetEntityStub.livePhotoStillAsset } }], ]); }); }); diff --git a/server/apps/microservices/src/processors.ts b/server/apps/microservices/src/processors.ts index 0a4b18b5e5..f621ad333f 100644 --- a/server/apps/microservices/src/processors.ts +++ b/server/apps/microservices/src/processors.ts @@ -3,7 +3,6 @@ import { FacialRecognitionService, IAssetFaceJob, IAssetJob, - IAssetUploadedJob, IBaseJob, IBulkEntityJob, IDeleteFilesJob, @@ -34,7 +33,7 @@ export class BackgroundTaskProcessor { ) {} @Process(JobName.ASSET_UPLOADED) - async onAssetUpload(job: Job) { + async onAssetUpload(job: Job) { await this.assetService.handleAssetUpload(job.data); } diff --git a/server/apps/microservices/src/processors/metadata-extraction.processor.ts b/server/apps/microservices/src/processors/metadata-extraction.processor.ts index 41bc2f4678..7152927f11 100644 --- a/server/apps/microservices/src/processors/metadata-extraction.processor.ts +++ b/server/apps/microservices/src/processors/metadata-extraction.processor.ts @@ -1,7 +1,7 @@ import { AssetCore, + IAssetJob, IAssetRepository, - IAssetUploadedJob, IBaseJob, IGeocodingRepository, IJobRepository, @@ -79,9 +79,8 @@ export class MetadataExtractionProcessor { : await this.assetRepository.getWithout(WithoutProperty.EXIF); for (const asset of assets) { - const fileName = asset.originalFileName; const name = asset.type === AssetType.VIDEO ? JobName.EXTRACT_VIDEO_METADATA : JobName.EXIF_EXTRACTION; - await this.jobRepository.queue({ name, data: { asset, fileName } }); + await this.jobRepository.queue({ name, data: { asset } }); } } catch (error: any) { this.logger.error(`Unable to queue metadata extraction`, error?.stack); @@ -89,7 +88,7 @@ export class MetadataExtractionProcessor { } @Process(JobName.EXIF_EXTRACTION) - async extractExifInfo(job: Job) { + async extractExifInfo(job: Job) { let asset = job.data.asset; try { @@ -194,7 +193,7 @@ export class MetadataExtractionProcessor { } @Process({ name: JobName.EXTRACT_VIDEO_METADATA, concurrency: 2 }) - async extractVideoMetadata(job: Job) { + async extractVideoMetadata(job: Job) { let asset = job.data.asset; if (!asset.isVisible) { diff --git a/server/libs/domain/src/asset/asset.service.spec.ts b/server/libs/domain/src/asset/asset.service.spec.ts index 3a023a1d10..b63eda69ee 100644 --- a/server/libs/domain/src/asset/asset.service.spec.ts +++ b/server/libs/domain/src/asset/asset.service.spec.ts @@ -20,7 +20,7 @@ describe(AssetService.name, () => { describe(`handle asset upload`, () => { it('should process an uploaded video', async () => { - const data = { asset: { type: AssetType.VIDEO } as AssetEntity, fileName: 'video.mp4' }; + const data = { asset: { type: AssetType.VIDEO } as AssetEntity }; await expect(sut.handleAssetUpload(data)).resolves.toBeUndefined(); @@ -33,7 +33,7 @@ describe(AssetService.name, () => { }); it('should process an uploaded image', async () => { - const data = { asset: { type: AssetType.IMAGE } as AssetEntity, fileName: 'image.jpg' }; + const data = { asset: { type: AssetType.IMAGE } as AssetEntity }; await sut.handleAssetUpload(data); diff --git a/server/libs/domain/src/asset/asset.service.ts b/server/libs/domain/src/asset/asset.service.ts index 42e301a21b..81ae2b95d3 100644 --- a/server/libs/domain/src/asset/asset.service.ts +++ b/server/libs/domain/src/asset/asset.service.ts @@ -1,7 +1,7 @@ import { AssetEntity, AssetType } from '@app/infra/entities'; import { Inject } from '@nestjs/common'; import { AuthUserDto } from '../auth'; -import { IAssetUploadedJob, IJobRepository, JobName } from '../job'; +import { IAssetJob, IJobRepository, JobName } from '../job'; import { AssetCore } from './asset.core'; import { IAssetRepository } from './asset.repository'; import { MapMarkerDto } from './dto/map-marker.dto'; @@ -17,7 +17,7 @@ export class AssetService { this.assetCore = new AssetCore(assetRepository, jobRepository); } - async handleAssetUpload(data: IAssetUploadedJob) { + async handleAssetUpload(data: IAssetJob) { await this.jobRepository.queue({ name: JobName.GENERATE_JPEG_THUMBNAIL, data }); if (data.asset.type == AssetType.VIDEO) { diff --git a/server/libs/domain/src/job/job.interface.ts b/server/libs/domain/src/job/job.interface.ts index 369724bec8..7ce6dc1e74 100644 --- a/server/libs/domain/src/job/job.interface.ts +++ b/server/libs/domain/src/job/job.interface.ts @@ -30,11 +30,6 @@ export interface IBulkEntityJob extends IBaseJob { ids: string[]; } -export interface IAssetUploadedJob extends IBaseJob { - asset: AssetEntity; - fileName: string; -} - export interface IDeleteFilesJob extends IBaseJob { files: Array; } diff --git a/server/libs/domain/src/job/job.repository.ts b/server/libs/domain/src/job/job.repository.ts index c09ff3c129..06c6b6eda7 100644 --- a/server/libs/domain/src/job/job.repository.ts +++ b/server/libs/domain/src/job/job.repository.ts @@ -2,7 +2,6 @@ import { JobName, QueueName } from './job.constants'; import { IAssetFaceJob, IAssetJob, - IAssetUploadedJob, IBaseJob, IBulkEntityJob, IDeleteFilesJob, @@ -26,7 +25,7 @@ export interface QueueStatus { export type JobItem = // Asset Upload - | { name: JobName.ASSET_UPLOADED; data: IAssetUploadedJob } + | { name: JobName.ASSET_UPLOADED; data: IAssetJob } // Transcoding | { name: JobName.QUEUE_VIDEO_CONVERSION; data: IBaseJob } @@ -48,8 +47,8 @@ export type JobItem = // Metadata Extraction | { name: JobName.QUEUE_METADATA_EXTRACTION; data: IBaseJob } - | { name: JobName.EXIF_EXTRACTION; data: IAssetUploadedJob } - | { name: JobName.EXTRACT_VIDEO_METADATA; data: IAssetUploadedJob } + | { name: JobName.EXIF_EXTRACTION; data: IAssetJob } + | { name: JobName.EXTRACT_VIDEO_METADATA; data: IAssetJob } // Object Tagging | { name: JobName.QUEUE_OBJECT_TAGGING; data: IBaseJob } diff --git a/server/libs/infra/src/repositories/job.repository.ts b/server/libs/infra/src/repositories/job.repository.ts index 557ab07802..f1da9f05c9 100644 --- a/server/libs/infra/src/repositories/job.repository.ts +++ b/server/libs/infra/src/repositories/job.repository.ts @@ -1,14 +1,4 @@ -import { - IAssetJob, - IAssetUploadedJob, - IBaseJob, - IJobRepository, - JobCounts, - JobItem, - JobName, - QueueName, - QueueStatus, -} from '@app/domain'; +import { IAssetJob, IBaseJob, IJobRepository, JobCounts, JobItem, JobName, QueueName, QueueStatus } from '@app/domain'; import { InjectQueue } from '@nestjs/bull'; import { Logger } from '@nestjs/common'; import { Queue, type JobCounts as BullJobCounts } from 'bull'; @@ -31,7 +21,7 @@ export class JobRepository implements IJobRepository { @InjectQueue(QueueName.BACKGROUND_TASK) private backgroundTask: Queue, @InjectQueue(QueueName.OBJECT_TAGGING) private objectTagging: Queue, @InjectQueue(QueueName.CLIP_ENCODING) private clipEmbedding: Queue, - @InjectQueue(QueueName.METADATA_EXTRACTION) private metadataExtraction: Queue, + @InjectQueue(QueueName.METADATA_EXTRACTION) private metadataExtraction: Queue, @InjectQueue(QueueName.RECOGNIZE_FACES) private recognizeFaces: Queue, @InjectQueue(QueueName.STORAGE_TEMPLATE_MIGRATION) private storageTemplateMigration: Queue, @InjectQueue(QueueName.THUMBNAIL_GENERATION) private generateThumbnail: Queue,