mirror of
https://github.com/certd/certd.git
synced 2026-07-03 01:57:32 +08:00
chore: auto fix 存储标记,确保fix只运行一次
This commit is contained in:
@@ -1,12 +1,23 @@
|
||||
import { Inject, Provide, Scope, ScopeEnum } from "@midwayjs/core";
|
||||
import { SysAutoFixSetting, SysSettingsService } from "@certd/lib-server";
|
||||
import { GoogleCommonEabAccountKeyFix } from "./google-common-eab-account-key-fix.js";
|
||||
import { OauthSubtypeBoundTypeFix } from "./oauth-subtype-bound-type-fix.js";
|
||||
import { CertInfoWildcardDomainCountFix } from "./cert-info-wildcard-domain-count-fix.js";
|
||||
import { SuiteContentWildcardDomainCountFix } from "./suite-content-wildcard-domain-count-fix.js";
|
||||
|
||||
type AutoFixTask = {
|
||||
key: string;
|
||||
fix: {
|
||||
init(): Promise<void>;
|
||||
};
|
||||
};
|
||||
|
||||
@Provide()
|
||||
@Scope(ScopeEnum.Request, { allowDowngrade: true })
|
||||
export class AutoFix {
|
||||
@Inject()
|
||||
sysSettingsService: SysSettingsService;
|
||||
|
||||
@Inject()
|
||||
googleCommonEabAccountKeyFix: GoogleCommonEabAccountKeyFix;
|
||||
|
||||
@@ -20,9 +31,34 @@ export class AutoFix {
|
||||
suiteContentWildcardDomainCountFix: SuiteContentWildcardDomainCountFix;
|
||||
|
||||
async init() {
|
||||
await this.googleCommonEabAccountKeyFix.init();
|
||||
await this.oauthSubtypeBoundTypeFix.init();
|
||||
await this.certInfoWildcardDomainCountFix.init();
|
||||
await this.suiteContentWildcardDomainCountFix.init();
|
||||
const setting = await this.sysSettingsService.getSetting<SysAutoFixSetting>(SysAutoFixSetting);
|
||||
setting.fixed = setting.fixed || {};
|
||||
const tasks: AutoFixTask[] = [
|
||||
{
|
||||
key: "google-common-eab-account-key",
|
||||
fix: this.googleCommonEabAccountKeyFix,
|
||||
},
|
||||
{
|
||||
key: "oauth-subtype-bound-type",
|
||||
fix: this.oauthSubtypeBoundTypeFix,
|
||||
},
|
||||
{
|
||||
key: "cert-info-wildcard-domain-count",
|
||||
fix: this.certInfoWildcardDomainCountFix,
|
||||
},
|
||||
{
|
||||
key: "suite-content-wildcard-domain-count",
|
||||
fix: this.suiteContentWildcardDomainCountFix,
|
||||
},
|
||||
];
|
||||
|
||||
for (const task of tasks) {
|
||||
if (setting.fixed?.[task.key]) {
|
||||
continue;
|
||||
}
|
||||
await task.fix.init();
|
||||
setting.fixed[task.key] = true;
|
||||
await this.sysSettingsService.saveSetting(setting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user