refactor(server): event emits (#10648)

* refactor(server): event emits

* refactor: change default priority to 0
This commit is contained in:
Jason Rasmussen
2024-06-27 15:54:20 -04:00
committed by GitHub
parent 7e99394c70
commit 72bf9439b0
25 changed files with 222 additions and 171 deletions

View File

@@ -15,14 +15,13 @@ import {
} from 'src/constants';
import { StorageCore, StorageFolder } from 'src/cores/storage.core';
import { SystemConfigCore } from 'src/cores/system-config.core';
import { OnServerEvent } from 'src/decorators';
import { AssetEntity, AssetType } from 'src/entities/asset.entity';
import { AssetPathType } from 'src/entities/move.entity';
import { IAlbumRepository } from 'src/interfaces/album.interface';
import { IAssetRepository } from 'src/interfaces/asset.interface';
import { ICryptoRepository } from 'src/interfaces/crypto.interface';
import { DatabaseLock, IDatabaseRepository } from 'src/interfaces/database.interface';
import { ServerAsyncEvent, ServerAsyncEventMap } from 'src/interfaces/event.interface';
import { OnEvents, SystemConfigUpdate } from 'src/interfaces/event.interface';
import { IEntityJob, JOBS_ASSET_PAGINATION_SIZE, JobStatus } from 'src/interfaces/job.interface';
import { ILoggerRepository } from 'src/interfaces/logger.interface';
import { IMoveRepository } from 'src/interfaces/move.interface';
@@ -46,7 +45,7 @@ interface RenderMetadata {
}
@Injectable()
export class StorageTemplateService {
export class StorageTemplateService implements OnEvents {
private configCore: SystemConfigCore;
private storageCore: StorageCore;
private _template: {
@@ -88,8 +87,7 @@ export class StorageTemplateService {
);
}
@OnServerEvent(ServerAsyncEvent.CONFIG_VALIDATE)
onValidateConfig({ newConfig }: ServerAsyncEventMap[ServerAsyncEvent.CONFIG_VALIDATE]) {
onConfigValidateEvent({ newConfig }: SystemConfigUpdate) {
try {
const { compiled } = this.compile(newConfig.storageTemplate.template);
this.render(compiled, {