refactor(server): filter on-event handlers by worker (#14085)

This commit is contained in:
Jason Rasmussen 2024-11-20 14:08:42 -05:00 committed by GitHub
parent c6e1dbec5c
commit 876893c823
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 24 additions and 70 deletions

View file

@ -2,7 +2,7 @@ import { SetMetadata, applyDecorators } from '@nestjs/common';
import { ApiExtension, ApiOperation, ApiProperty, ApiTags } from '@nestjs/swagger';
import _ from 'lodash';
import { ADDED_IN_PREFIX, DEPRECATED_IN_PREFIX, LIFECYCLE_EXTENSION } from 'src/constants';
import { MetadataKey } from 'src/enum';
import { ImmichWorker, MetadataKey } from 'src/enum';
import { EmitEvent } from 'src/interfaces/event.interface';
import { JobName, QueueName } from 'src/interfaces/job.interface';
import { setUnion } from 'src/utils/set';
@ -120,6 +120,8 @@ export type EventConfig = {
server?: boolean;
/** lower value has higher priority, defaults to 0 */
priority?: number;
/** register events for these workers, defaults to all workers */
workers?: ImmichWorker[];
};
export const OnEvent = (config: EventConfig) => SetMetadata(MetadataKey.EVENT_CONFIG, config);