mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
perf: 通知选择器优化
This commit is contained in:
@@ -98,10 +98,22 @@ export function createAxiosService({ logger }: { logger: Logger }) {
|
||||
config.timeout = 15000;
|
||||
}
|
||||
let agents = defaultAgents;
|
||||
if (config.skipSslVerify) {
|
||||
logger.info('跳过SSL验证');
|
||||
agents = createAgent({ rejectUnauthorized: false } as any);
|
||||
if (config.skipSslVerify || config.httpProxy) {
|
||||
let rejectUnauthorized = true;
|
||||
if (config.skipSslVerify) {
|
||||
logger.info('跳过SSL验证');
|
||||
rejectUnauthorized = false;
|
||||
}
|
||||
const proxy: any = {};
|
||||
if (config.httpProxy) {
|
||||
logger.info('使用自定义http代理:', config.httpProxy);
|
||||
proxy.httpProxy = config.httpProxy;
|
||||
proxy.httpsProxy = config.httpProxy;
|
||||
}
|
||||
|
||||
agents = createAgent({ rejectUnauthorized, ...proxy } as any);
|
||||
}
|
||||
|
||||
delete config.skipSslVerify;
|
||||
config.httpsAgent = agents.httpsAgent;
|
||||
config.httpAgent = agents.httpAgent;
|
||||
@@ -200,6 +212,7 @@ export type HttpRequestConfig<D = any> = {
|
||||
skipCheckRes?: boolean;
|
||||
logParams?: boolean;
|
||||
logRes?: boolean;
|
||||
httpProxy?: string;
|
||||
} & AxiosRequestConfig<D>;
|
||||
export type HttpClient = {
|
||||
request<D = any, R = any>(config: HttpRequestConfig<D>): Promise<HttpClientResponse<R>>;
|
||||
|
||||
@@ -388,6 +388,7 @@ export class Executor {
|
||||
if (!notification.when.includes(when)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (notification.type === "email") {
|
||||
try {
|
||||
await this.options.emailService?.send({
|
||||
@@ -401,7 +402,16 @@ export class Executor {
|
||||
} else {
|
||||
try {
|
||||
//构建notification插件,发送通知
|
||||
const notifyConfig = await this.options.notificationService.getById(notification.notificationId);
|
||||
let notifyConfig: any;
|
||||
if (notification.notificationId === 0) {
|
||||
notifyConfig = await this.options.notificationService.getDefault();
|
||||
} else {
|
||||
notifyConfig = await this.options.notificationService.getById(notification.notificationId);
|
||||
}
|
||||
if (notifyConfig == null) {
|
||||
throw new Error(`通知配置<id:${notification.notificationId}>不存在`);
|
||||
}
|
||||
|
||||
const notificationPlugin = notificationRegistry.get(notifyConfig.type);
|
||||
const notificationCls: any = notificationPlugin.target;
|
||||
const notificationSender = new notificationCls();
|
||||
|
||||
Reference in New Issue
Block a user