fix(server): validation events actually throwing an error (#8172)

* fix validation events

* add e2e test
This commit is contained in:
Daniel Dietzler
2024-03-21 23:59:21 +01:00
committed by GitHub
parent 508f32c08a
commit d6823b128c
5 changed files with 36 additions and 8 deletions
+2 -2
View File
@@ -1,5 +1,4 @@
import { BadRequestException, Inject, Injectable } from '@nestjs/common';
import { OnEvent } from '@nestjs/event-emitter';
import { instanceToPlain } from 'class-transformer';
import _ from 'lodash';
import {
@@ -13,6 +12,7 @@ import {
supportedYearTokens,
} from 'src/constants';
import { SystemConfigCore } from 'src/cores/system-config.core';
import { OnEventInternal } from 'src/decorators';
import { SystemConfigTemplateStorageOptionDto } from 'src/dtos/system-config-storage-template.dto';
import { SystemConfigDto, mapConfig } from 'src/dtos/system-config.dto';
import { LogLevel, SystemConfig } from 'src/entities/system-config.entity';
@@ -61,7 +61,7 @@ export class SystemConfigService {
return mapConfig(config);
}
@OnEvent(InternalEvent.VALIDATE_CONFIG)
@OnEventInternal(InternalEvent.VALIDATE_CONFIG)
validateConfig({ newConfig, oldConfig }: InternalEventMap[InternalEvent.VALIDATE_CONFIG]) {
if (!_.isEqual(instanceToPlain(newConfig.logging), oldConfig.logging) && this.getEnvLogLevel()) {
throw new Error('Logging cannot be changed while the environment variable LOG_LEVEL is set.');