fix(server): skip smtp validation if unchanged (#12111)

* fix(server): skip smtp validation if unchanged

* update comparison + convert config to plain object
This commit is contained in:
Michel Heusschen 2024-08-29 20:10:09 +02:00 committed by GitHub
parent d08a20bd57
commit 74f18a4523
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 3 deletions

View file

@ -18,6 +18,7 @@ import { SystemConfigDto, SystemConfigTemplateStorageOptionDto, mapConfig } from
import { ArgOf, ClientEvent, IEventRepository, ServerEvent } from 'src/interfaces/event.interface';
import { ILoggerRepository } from 'src/interfaces/logger.interface';
import { ISystemMetadataRepository } from 'src/interfaces/system-metadata.interface';
import { toPlainObject } from 'src/utils/object';
@Injectable()
export class SystemConfigService {
@ -63,7 +64,7 @@ export class SystemConfigService {
const oldConfig = await this.core.getConfig({ withCache: false });
try {
await this.eventRepository.emit('config.validate', { newConfig: dto, oldConfig });
await this.eventRepository.emit('config.validate', { newConfig: toPlainObject(dto), oldConfig });
} catch (error) {
this.logger.warn(`Unable to save system config due to a validation error: ${error}`);
throw new BadRequestException(error instanceof Error ? error.message : error);