fix(core): Fix frontend.settings external hook execution (#7496)

This commit is contained in:
Ricardo Espinoza 2023-10-23 11:46:13 -04:00 committed by GitHub
parent 4e66023cd4
commit 774fe202bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,11 +30,14 @@ import {
getWorkflowHistoryPruneTime,
} from '@/workflows/workflowHistory/workflowHistoryHelper.ee';
import { UserManagementMailer } from '@/UserManagement/email';
import type { CommunityPackagesService } from '@/services/communityPackages.service';
@Service()
export class FrontendService {
settings: IN8nUISettings;
private communityPackagesService?: CommunityPackagesService;
constructor(
private readonly loadNodesAndCredentials: LoadNodesAndCredentials,
private readonly credentialTypes: CredentialTypes,
@ -44,6 +47,13 @@ export class FrontendService {
private readonly instanceSettings: InstanceSettings,
) {
this.initSettings();
if (config.getEnv('nodes.communityPackages.enabled')) {
// eslint-disable-next-line @typescript-eslint/naming-convention
void import('@/services/communityPackages.service').then(({ CommunityPackagesService }) => {
this.communityPackagesService = Container.get(CommunityPackagesService);
});
}
}
private initSettings() {
@ -198,7 +208,7 @@ export class FrontendService {
this.writeStaticJSON('credentials', credentials);
}
async getSettings(): Promise<IN8nUISettings> {
getSettings(): IN8nUISettings {
const restEndpoint = config.getEnv('endpoints.rest');
// Update all urls, in case `WEBHOOK_URL` was updated by `--tunnel`
@ -275,10 +285,8 @@ export class FrontendService {
});
}
if (config.getEnv('nodes.communityPackages.enabled')) {
// eslint-disable-next-line @typescript-eslint/naming-convention
const { CommunityPackagesService } = await import('@/services/communityPackages.service');
this.settings.missingPackages = Container.get(CommunityPackagesService).hasMissingPackages;
if (this.communityPackagesService) {
this.settings.missingPackages = this.communityPackagesService.hasMissingPackages;
}
this.settings.mfa.enabled = config.get('mfa.enabled');