perf: 优化证书申请成功通知发送方式

This commit is contained in:
xiaojunnuo
2024-11-27 12:36:28 +08:00
parent 7e5ea0cee0
commit 8002a56efc
24 changed files with 382 additions and 42 deletions
@@ -30,6 +30,18 @@ export class BarkNotification extends BaseNotification {
helper: '你的bark服务地址+key',
})
webhook = '';
@NotificationInput({
title: '忽略证书校验',
value: false,
component: {
name: 'a-switch',
vModel: 'checked',
},
required: false,
})
skipSslVerify: boolean;
async send(body: NotificationBody) {
if (!this.webhook) {
throw new Error('服务器地址不能为空');
@@ -47,6 +59,7 @@ export class BarkNotification extends BaseNotification {
'Content-Type': 'application/json; charset=utf-8',
},
data: payload,
skipSslVerify: this.skipSslVerify,
});
}
}
@@ -43,6 +43,17 @@ export class ServerChanNotification extends BaseNotification {
})
noip: boolean;
@NotificationInput({
title: '忽略证书校验',
value: false,
component: {
name: 'a-switch',
vModel: 'checked',
},
required: false,
})
skipSslVerify: boolean;
async send(body: NotificationBody) {
if (!this.sendKey) {
throw new Error('sendKey不能为空');
@@ -54,6 +65,7 @@ export class ServerChanNotification extends BaseNotification {
text: body.title,
desp: body.content + '[查看详情](' + body.url + ')',
},
skipSslVerify: this.skipSslVerify,
});
}
}
@@ -49,6 +49,17 @@ export class VoceChatNotification extends BaseNotification {
})
targetId = '';
@NotificationInput({
title: '忽略证书校验',
value: false,
component: {
name: 'a-switch',
vModel: 'checked',
},
required: false,
})
skipSslVerify: boolean;
async send(body: NotificationBody) {
if (!this.apiKey) {
throw new Error('API Key不能为空');
@@ -68,6 +79,7 @@ export class VoceChatNotification extends BaseNotification {
'Content-Type': 'text/markdown',
},
data: `# ${body.title}\n\n${body.content}\n[查看详情](${body.url})`,
skipSslVerify: this.skipSslVerify,
});
}
}
@@ -82,6 +82,17 @@ export class WebhookNotification extends BaseNotification {
})
template = '';
@NotificationInput({
title: '忽略证书校验',
value: false,
component: {
name: 'a-switch',
vModel: 'checked',
},
required: false,
})
skipSslVerify: boolean;
replaceTemplate(target: string, body: any, urlEncode = false) {
let bodyStr = target;
const keys = Object.keys(body);
@@ -143,6 +154,7 @@ export class WebhookNotification extends BaseNotification {
...headers,
},
data: data,
skipSslVerify: this.skipSslVerify,
});
} catch (e) {
if (e.response?.data) {