2023-12-14 11:55:40 -05:00
|
|
|
import { BadRequestException, Inject, Injectable } from '@nestjs/common';
|
2024-03-20 21:20:38 +01:00
|
|
|
import { FeatureFlag, SystemConfigCore } from 'src/cores/system-config.core';
|
2024-03-20 19:32:04 +01:00
|
|
|
import { ConcurrentQueueName, JobCommand, JobName, QueueName } from 'src/domain/job/job.constants';
|
2024-03-20 23:53:07 +01:00
|
|
|
import { mapAsset } from 'src/dtos/asset-response.dto';
|
|
|
|
|
import { AllJobStatusResponseDto, JobCommandDto, JobStatusDto } from 'src/dtos/job.dto';
|
2024-03-20 16:02:51 -05:00
|
|
|
import { AssetType } from 'src/entities/asset.entity';
|
2024-03-20 19:32:04 +01:00
|
|
|
import { ImmichLogger } from 'src/infra/logger';
|
2024-03-20 21:42:58 +01:00
|
|
|
import { IAssetRepository } from 'src/interfaces/asset.repository';
|
|
|
|
|
import { ClientEvent, ICommunicationRepository } from 'src/interfaces/communication.repository';
|
|
|
|
|
import { IJobRepository, JobHandler, JobItem, JobStatus, QueueCleanType } from 'src/interfaces/job.repository';
|
|
|
|
|
import { IPersonRepository } from 'src/interfaces/person.repository';
|
|
|
|
|
import { ISystemConfigRepository } from 'src/interfaces/system-config.repository';
|
2023-03-20 11:55:28 -04:00
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
|
export class JobService {
|
2023-12-14 11:55:40 -05:00
|
|
|
private logger = new ImmichLogger(JobService.name);
|
2023-06-01 06:32:51 -04:00
|
|
|
private configCore: SystemConfigCore;
|
2023-03-20 11:55:28 -04:00
|
|
|
|
2023-05-26 15:43:24 -04:00
|
|
|
constructor(
|
|
|
|
|
@Inject(IAssetRepository) private assetRepository: IAssetRepository,
|
|
|
|
|
@Inject(ICommunicationRepository) private communicationRepository: ICommunicationRepository,
|
|
|
|
|
@Inject(IJobRepository) private jobRepository: IJobRepository,
|
2023-06-01 06:32:51 -04:00
|
|
|
@Inject(ISystemConfigRepository) configRepository: ISystemConfigRepository,
|
2023-10-06 15:48:11 -05:00
|
|
|
@Inject(IPersonRepository) private personRepository: IPersonRepository,
|
2023-06-01 06:32:51 -04:00
|
|
|
) {
|
2023-10-09 02:51:03 +02:00
|
|
|
this.configCore = SystemConfigCore.create(configRepository);
|
2023-06-01 06:32:51 -04:00
|
|
|
}
|
2023-05-17 13:07:17 -04:00
|
|
|
|
2023-06-16 15:36:07 -04:00
|
|
|
async handleCommand(queueName: QueueName, dto: JobCommandDto): Promise<JobStatusDto> {
|
2023-03-20 11:55:28 -04:00
|
|
|
this.logger.debug(`Handling command: queue=${queueName},force=${dto.force}`);
|
|
|
|
|
|
|
|
|
|
switch (dto.command) {
|
2024-02-02 04:18:00 +01:00
|
|
|
case JobCommand.START: {
|
2023-06-16 15:36:07 -04:00
|
|
|
await this.start(queueName, dto);
|
|
|
|
|
break;
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-03-20 11:55:28 -04:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case JobCommand.PAUSE: {
|
2023-06-16 15:36:07 -04:00
|
|
|
await this.jobRepository.pause(queueName);
|
|
|
|
|
break;
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-03-20 11:55:28 -04:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case JobCommand.RESUME: {
|
2023-06-16 15:36:07 -04:00
|
|
|
await this.jobRepository.resume(queueName);
|
|
|
|
|
break;
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-03-28 14:25:22 -04:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case JobCommand.EMPTY: {
|
2023-06-16 15:36:07 -04:00
|
|
|
await this.jobRepository.empty(queueName);
|
|
|
|
|
break;
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-12-05 10:07:20 +08:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case JobCommand.CLEAR_FAILED: {
|
2023-12-05 10:07:20 +08:00
|
|
|
const failedJobs = await this.jobRepository.clear(queueName, QueueCleanType.FAILED);
|
|
|
|
|
this.logger.debug(`Cleared failed jobs: ${failedJobs}`);
|
|
|
|
|
break;
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-03-20 11:55:28 -04:00
|
|
|
}
|
2023-06-16 15:36:07 -04:00
|
|
|
|
|
|
|
|
return this.getJobStatus(queueName);
|
2023-03-20 11:55:28 -04:00
|
|
|
}
|
|
|
|
|
|
2023-04-01 22:46:07 +02:00
|
|
|
async getJobStatus(queueName: QueueName): Promise<JobStatusDto> {
|
|
|
|
|
const [jobCounts, queueStatus] = await Promise.all([
|
|
|
|
|
this.jobRepository.getJobCounts(queueName),
|
|
|
|
|
this.jobRepository.getQueueStatus(queueName),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
return { jobCounts, queueStatus };
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-20 11:55:28 -04:00
|
|
|
async getAllJobsStatus(): Promise<AllJobStatusResponseDto> {
|
|
|
|
|
const response = new AllJobStatusResponseDto();
|
|
|
|
|
for (const queueName of Object.values(QueueName)) {
|
2023-04-01 22:46:07 +02:00
|
|
|
response[queueName] = await this.getJobStatus(queueName);
|
2023-03-20 11:55:28 -04:00
|
|
|
}
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async start(name: QueueName, { force }: JobCommandDto): Promise<void> {
|
2023-04-01 22:46:07 +02:00
|
|
|
const { isActive } = await this.jobRepository.getQueueStatus(name);
|
2023-03-20 11:55:28 -04:00
|
|
|
if (isActive) {
|
|
|
|
|
throw new BadRequestException(`Job is already running`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (name) {
|
2024-02-02 04:18:00 +01:00
|
|
|
case QueueName.VIDEO_CONVERSION: {
|
2023-03-20 11:55:28 -04:00
|
|
|
return this.jobRepository.queue({ name: JobName.QUEUE_VIDEO_CONVERSION, data: { force } });
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-03-20 11:55:28 -04:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case QueueName.STORAGE_TEMPLATE_MIGRATION: {
|
2023-03-20 11:55:28 -04:00
|
|
|
return this.jobRepository.queue({ name: JobName.STORAGE_TEMPLATE_MIGRATION });
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-03-20 11:55:28 -04:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case QueueName.MIGRATION: {
|
2023-09-25 17:07:21 +02:00
|
|
|
return this.jobRepository.queue({ name: JobName.QUEUE_MIGRATION });
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-09-25 17:07:21 +02:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case QueueName.SMART_SEARCH: {
|
2024-01-29 09:51:22 -05:00
|
|
|
await this.configCore.requireFeature(FeatureFlag.SMART_SEARCH);
|
|
|
|
|
return this.jobRepository.queue({ name: JobName.QUEUE_SMART_SEARCH, data: { force } });
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-03-20 11:55:28 -04:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case QueueName.METADATA_EXTRACTION: {
|
2023-03-20 11:55:28 -04:00
|
|
|
return this.jobRepository.queue({ name: JobName.QUEUE_METADATA_EXTRACTION, data: { force } });
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-03-20 11:55:28 -04:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case QueueName.SIDECAR: {
|
2023-08-25 00:15:03 -04:00
|
|
|
await this.configCore.requireFeature(FeatureFlag.SIDECAR);
|
feat(server): xmp sidecar metadata (#2466)
* initial commit for XMP sidecar support
* Added support for 'missing' metadata files to include those without sidecar files, now detects sidecar files in the filesystem for media already ingested but the sidecar was created afterwards
* didn't mean to commit default log level during testing
* new sidecar logic for video metadata as well
* Added xml mimetype for sidecars only
* don't need capture group for this regex
* wrong default value reverted
* simplified the move here - keep it in the same try catch since the outcome is to move the media back anyway
* simplified setter logic
Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
* simplified logic per suggestions
* sidecar is now its own queue with a discover and sync, updated UI for the new job queueing
* queue a sidecar job for every asset based on discovery or sync, though the logic is almost identical aside from linking the sidecar
* now queue sidecar jobs for each assset, though logic is mostly the same between discovery and sync
* simplified logic of filename extraction and asset instantiation
* not sure how that got deleted..
* updated code per suggestions and comments in the PR
* stat was not being used, removed the variable set
* better type checking, using in-scope variables for exif getter instead of passing in every time
* removed commented out test
* ran and resolved all lints, formats, checks, and tests
* resolved suggested change in PR
* made getExifProperty more dynamic with multiple possible args for fallbacks, fixed typo, used generic in function for better type checking
* better error handling and moving files back to positions on move or save failure
* regenerated api
* format fixes
* Added XMP documentation
* documentation typo
* Merged in main
* missed merge conflict
* more changes due to a merge
* Resolving conflicts
* added icon for sidecar jobs
---------
Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
2023-05-24 21:59:30 -04:00
|
|
|
return this.jobRepository.queue({ name: JobName.QUEUE_SIDECAR, data: { force } });
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
feat(server): xmp sidecar metadata (#2466)
* initial commit for XMP sidecar support
* Added support for 'missing' metadata files to include those without sidecar files, now detects sidecar files in the filesystem for media already ingested but the sidecar was created afterwards
* didn't mean to commit default log level during testing
* new sidecar logic for video metadata as well
* Added xml mimetype for sidecars only
* don't need capture group for this regex
* wrong default value reverted
* simplified the move here - keep it in the same try catch since the outcome is to move the media back anyway
* simplified setter logic
Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
* simplified logic per suggestions
* sidecar is now its own queue with a discover and sync, updated UI for the new job queueing
* queue a sidecar job for every asset based on discovery or sync, though the logic is almost identical aside from linking the sidecar
* now queue sidecar jobs for each assset, though logic is mostly the same between discovery and sync
* simplified logic of filename extraction and asset instantiation
* not sure how that got deleted..
* updated code per suggestions and comments in the PR
* stat was not being used, removed the variable set
* better type checking, using in-scope variables for exif getter instead of passing in every time
* removed commented out test
* ran and resolved all lints, formats, checks, and tests
* resolved suggested change in PR
* made getExifProperty more dynamic with multiple possible args for fallbacks, fixed typo, used generic in function for better type checking
* better error handling and moving files back to positions on move or save failure
* regenerated api
* format fixes
* Added XMP documentation
* documentation typo
* Merged in main
* missed merge conflict
* more changes due to a merge
* Resolving conflicts
* added icon for sidecar jobs
---------
Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
2023-05-24 21:59:30 -04:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case QueueName.THUMBNAIL_GENERATION: {
|
2023-03-20 11:55:28 -04:00
|
|
|
return this.jobRepository.queue({ name: JobName.QUEUE_GENERATE_THUMBNAILS, data: { force } });
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-03-20 11:55:28 -04:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case QueueName.FACE_DETECTION: {
|
2023-08-25 00:15:03 -04:00
|
|
|
await this.configCore.requireFeature(FeatureFlag.FACIAL_RECOGNITION);
|
2024-01-18 00:08:48 -05:00
|
|
|
return this.jobRepository.queue({ name: JobName.QUEUE_FACE_DETECTION, data: { force } });
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2024-01-18 00:08:48 -05:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case QueueName.FACIAL_RECOGNITION: {
|
2024-01-18 00:08:48 -05:00
|
|
|
await this.configCore.requireFeature(FeatureFlag.FACIAL_RECOGNITION);
|
|
|
|
|
return this.jobRepository.queue({ name: JobName.QUEUE_FACIAL_RECOGNITION, data: { force } });
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-05-17 13:07:17 -04:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case QueueName.LIBRARY: {
|
2023-09-20 13:16:33 +02:00
|
|
|
return this.jobRepository.queue({ name: JobName.LIBRARY_QUEUE_SCAN_ALL, data: { force } });
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-09-20 13:16:33 +02:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
default: {
|
2023-03-20 11:55:28 -04:00
|
|
|
throw new BadRequestException(`Invalid job name: ${name}`);
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-03-20 11:55:28 -04:00
|
|
|
}
|
|
|
|
|
}
|
2023-05-26 15:43:24 -04:00
|
|
|
|
2024-01-01 13:16:44 -05:00
|
|
|
async init(jobHandlers: Record<JobName, JobHandler>) {
|
2023-06-01 06:32:51 -04:00
|
|
|
const config = await this.configCore.getConfig();
|
|
|
|
|
for (const queueName of Object.values(QueueName)) {
|
2023-12-29 18:41:33 +00:00
|
|
|
let concurrency = 1;
|
2024-01-18 00:08:48 -05:00
|
|
|
|
|
|
|
|
if (this.isConcurrentQueue(queueName)) {
|
2023-12-29 18:41:33 +00:00
|
|
|
concurrency = config.job[queueName].concurrency;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-01 06:32:51 -04:00
|
|
|
this.logger.debug(`Registering ${queueName} with a concurrency of ${concurrency}`);
|
|
|
|
|
this.jobRepository.addHandler(queueName, concurrency, async (item: JobItem): Promise<void> => {
|
|
|
|
|
const { name, data } = item;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const handler = jobHandlers[name];
|
2024-03-15 14:16:54 +01:00
|
|
|
const status = await handler(data);
|
|
|
|
|
if (status === JobStatus.SUCCESS || status == JobStatus.SKIPPED) {
|
2023-06-01 06:32:51 -04:00
|
|
|
await this.onDone(item);
|
|
|
|
|
}
|
|
|
|
|
} catch (error: Error | any) {
|
2023-09-20 13:16:33 +02:00
|
|
|
this.logger.error(`Unable to run job handler (${queueName}/${name}): ${error}`, error?.stack, data);
|
2023-06-01 06:32:51 -04:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.configCore.config$.subscribe((config) => {
|
2024-01-18 00:08:48 -05:00
|
|
|
this.logger.debug(`Updating queue concurrency settings`);
|
2023-06-01 06:32:51 -04:00
|
|
|
for (const queueName of Object.values(QueueName)) {
|
2023-12-29 18:41:33 +00:00
|
|
|
let concurrency = 1;
|
2024-01-18 00:08:48 -05:00
|
|
|
if (this.isConcurrentQueue(queueName)) {
|
2023-12-29 18:41:33 +00:00
|
|
|
concurrency = config.job[queueName].concurrency;
|
|
|
|
|
}
|
2023-06-01 06:32:51 -04:00
|
|
|
this.logger.debug(`Setting ${queueName} concurrency to ${concurrency}`);
|
|
|
|
|
this.jobRepository.setConcurrency(queueName, concurrency);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-18 00:08:48 -05:00
|
|
|
private isConcurrentQueue(name: QueueName): name is ConcurrentQueueName {
|
|
|
|
|
return ![QueueName.FACIAL_RECOGNITION, QueueName.STORAGE_TEMPLATE_MIGRATION].includes(name);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-26 15:43:24 -04:00
|
|
|
async handleNightlyJobs() {
|
2024-01-01 15:45:42 -05:00
|
|
|
await this.jobRepository.queueAll([
|
|
|
|
|
{ name: JobName.ASSET_DELETION_CHECK },
|
|
|
|
|
{ name: JobName.USER_DELETE_CHECK },
|
|
|
|
|
{ name: JobName.PERSON_CLEANUP },
|
|
|
|
|
{ name: JobName.QUEUE_GENERATE_THUMBNAILS, data: { force: false } },
|
|
|
|
|
{ name: JobName.CLEAN_OLD_AUDIT_LOGS },
|
2024-01-12 18:43:36 -06:00
|
|
|
{ name: JobName.USER_SYNC_USAGE },
|
2024-01-25 01:27:39 -05:00
|
|
|
{ name: JobName.QUEUE_FACIAL_RECOGNITION, data: { force: false } },
|
2024-01-01 15:45:42 -05:00
|
|
|
]);
|
2023-05-26 15:43:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Queue follow up jobs
|
|
|
|
|
*/
|
2023-06-01 16:07:45 -04:00
|
|
|
private async onDone(item: JobItem) {
|
2023-05-26 15:43:24 -04:00
|
|
|
switch (item.name) {
|
|
|
|
|
case JobName.SIDECAR_SYNC:
|
2024-02-02 04:18:00 +01:00
|
|
|
case JobName.SIDECAR_DISCOVERY: {
|
2023-06-01 16:07:45 -04:00
|
|
|
await this.jobRepository.queue({ name: JobName.METADATA_EXTRACTION, data: item.data });
|
2023-05-26 15:43:24 -04:00
|
|
|
break;
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-05-26 15:43:24 -04:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case JobName.SIDECAR_WRITE: {
|
2023-11-30 04:52:28 +01:00
|
|
|
await this.jobRepository.queue({
|
|
|
|
|
name: JobName.METADATA_EXTRACTION,
|
|
|
|
|
data: { id: item.data.id, source: 'sidecar-write' },
|
|
|
|
|
});
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-11-30 04:52:28 +01:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case JobName.METADATA_EXTRACTION: {
|
2023-11-30 04:52:28 +01:00
|
|
|
if (item.data.source === 'sidecar-write') {
|
2024-03-14 01:58:09 -04:00
|
|
|
const [asset] = await this.assetRepository.getByIdsWithAllRelations([item.data.id]);
|
2023-11-30 04:52:28 +01:00
|
|
|
if (asset) {
|
2023-12-13 12:23:51 -05:00
|
|
|
this.communicationRepository.send(ClientEvent.ASSET_UPDATE, asset.ownerId, mapAsset(asset));
|
2023-11-30 04:52:28 +01:00
|
|
|
}
|
|
|
|
|
}
|
2023-08-15 21:34:57 -04:00
|
|
|
await this.jobRepository.queue({ name: JobName.LINK_LIVE_PHOTOS, data: item.data });
|
|
|
|
|
break;
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-08-15 21:34:57 -04:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case JobName.LINK_LIVE_PHOTOS: {
|
2023-05-26 15:43:24 -04:00
|
|
|
await this.jobRepository.queue({ name: JobName.STORAGE_TEMPLATE_MIGRATION_SINGLE, data: item.data });
|
|
|
|
|
break;
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-05-26 15:43:24 -04:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case JobName.STORAGE_TEMPLATE_MIGRATION_SINGLE: {
|
2023-05-27 16:49:57 -05:00
|
|
|
if (item.data.source === 'upload') {
|
|
|
|
|
await this.jobRepository.queue({ name: JobName.GENERATE_JPEG_THUMBNAIL, data: item.data });
|
|
|
|
|
}
|
|
|
|
|
break;
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-05-27 16:49:57 -05:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case JobName.GENERATE_PERSON_THUMBNAIL: {
|
2023-10-06 15:48:11 -05:00
|
|
|
const { id } = item.data;
|
|
|
|
|
const person = await this.personRepository.getById(id);
|
|
|
|
|
if (person) {
|
2023-12-13 12:23:51 -05:00
|
|
|
this.communicationRepository.send(ClientEvent.PERSON_THUMBNAIL, person.ownerId, person.id);
|
2023-10-06 15:48:11 -05:00
|
|
|
}
|
|
|
|
|
break;
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-10-06 15:48:11 -05:00
|
|
|
|
2023-05-26 15:43:24 -04:00
|
|
|
case JobName.GENERATE_JPEG_THUMBNAIL: {
|
2024-01-01 15:45:42 -05:00
|
|
|
const jobs: JobItem[] = [
|
|
|
|
|
{ name: JobName.GENERATE_WEBP_THUMBNAIL, data: item.data },
|
|
|
|
|
{ name: JobName.GENERATE_THUMBHASH_THUMBNAIL, data: item.data },
|
|
|
|
|
];
|
2023-05-26 15:43:24 -04:00
|
|
|
|
2024-02-28 23:23:21 -05:00
|
|
|
if (item.data.source === 'upload') {
|
|
|
|
|
jobs.push({ name: JobName.SMART_SEARCH, data: item.data }, { name: JobName.FACE_DETECTION, data: item.data });
|
|
|
|
|
|
|
|
|
|
const [asset] = await this.assetRepository.getByIds([item.data.id]);
|
|
|
|
|
if (asset) {
|
|
|
|
|
if (asset.type === AssetType.VIDEO) {
|
|
|
|
|
jobs.push({ name: JobName.VIDEO_CONVERSION, data: item.data });
|
|
|
|
|
} else if (asset.livePhotoVideoId) {
|
|
|
|
|
jobs.push({ name: JobName.VIDEO_CONVERSION, data: { id: asset.livePhotoVideoId } });
|
|
|
|
|
}
|
2023-07-05 01:36:16 -04:00
|
|
|
}
|
2023-05-26 15:43:24 -04:00
|
|
|
}
|
2024-01-01 15:45:42 -05:00
|
|
|
|
|
|
|
|
await this.jobRepository.queueAll(jobs);
|
2023-05-26 15:43:24 -04:00
|
|
|
break;
|
|
|
|
|
}
|
2023-10-06 15:48:11 -05:00
|
|
|
|
|
|
|
|
case JobName.GENERATE_WEBP_THUMBNAIL: {
|
|
|
|
|
if (item.data.source !== 'upload') {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-14 01:58:09 -04:00
|
|
|
const [asset] = await this.assetRepository.getByIdsWithAllRelations([item.data.id]);
|
2023-12-03 22:35:22 +00:00
|
|
|
|
|
|
|
|
// Only live-photo motion part will be marked as not visible immediately on upload. Skip notifying clients
|
|
|
|
|
if (asset && asset.isVisible) {
|
2023-12-13 12:23:51 -05:00
|
|
|
this.communicationRepository.send(ClientEvent.UPLOAD_SUCCESS, asset.ownerId, mapAsset(asset));
|
2023-10-06 15:48:11 -05:00
|
|
|
}
|
2024-01-18 00:08:48 -05:00
|
|
|
break;
|
|
|
|
|
}
|
2024-03-08 17:49:39 -05:00
|
|
|
|
|
|
|
|
case JobName.USER_DELETION: {
|
|
|
|
|
this.communicationRepository.broadcast(ClientEvent.USER_DELETE, item.data.id);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2023-05-26 15:43:24 -04:00
|
|
|
}
|
|
|
|
|
}
|
2023-03-20 11:55:28 -04:00
|
|
|
}
|