2026-05-31 01:41:33 +08:00
|
|
|
import { BaseNotification, IsNotification, NotificationBody, NotificationInput } from "@certd/pipeline";
|
2024-11-26 15:13:57 +08:00
|
|
|
|
|
|
|
|
@IsNotification({
|
2026-05-31 01:41:33 +08:00
|
|
|
name: "slack",
|
|
|
|
|
title: "Slack通知",
|
|
|
|
|
desc: "Slack消息推送通知",
|
2024-11-30 01:57:09 +08:00
|
|
|
needPlus: true,
|
2024-11-26 15:13:57 +08:00
|
|
|
})
|
|
|
|
|
export class SlackNotification extends BaseNotification {
|
|
|
|
|
@NotificationInput({
|
2026-05-31 01:41:33 +08:00
|
|
|
title: "webhook地址",
|
2024-11-26 15:13:57 +08:00
|
|
|
component: {
|
2026-05-31 01:41:33 +08:00
|
|
|
placeholder: "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX",
|
2024-11-26 15:13:57 +08:00
|
|
|
},
|
2026-05-31 01:41:33 +08:00
|
|
|
helper: "[APPS](https://api.slack.com/apps/)->进入APP->incoming-webhooks->Add New Webhook to Workspace",
|
2024-11-26 15:13:57 +08:00
|
|
|
required: true,
|
|
|
|
|
})
|
2026-05-31 01:41:33 +08:00
|
|
|
webhook = "";
|
2024-11-26 15:13:57 +08:00
|
|
|
|
2024-12-02 14:06:55 +08:00
|
|
|
@NotificationInput({
|
2026-05-31 01:41:33 +08:00
|
|
|
title: "代理",
|
2024-12-02 14:06:55 +08:00
|
|
|
component: {
|
2026-05-31 01:41:33 +08:00
|
|
|
placeholder: "http://xxxxx:xx",
|
2024-12-02 14:06:55 +08:00
|
|
|
},
|
2026-05-31 01:41:33 +08:00
|
|
|
helper: "使用https_proxy",
|
2024-12-02 14:06:55 +08:00
|
|
|
required: false,
|
|
|
|
|
})
|
2026-05-31 01:41:33 +08:00
|
|
|
httpsProxy = "";
|
2024-12-02 14:06:55 +08:00
|
|
|
|
|
|
|
|
@NotificationInput({
|
2026-05-31 01:41:33 +08:00
|
|
|
title: "忽略证书校验",
|
2024-12-02 14:06:55 +08:00
|
|
|
value: false,
|
|
|
|
|
component: {
|
2026-05-31 01:41:33 +08:00
|
|
|
name: "a-switch",
|
|
|
|
|
vModel: "checked",
|
2024-12-02 14:06:55 +08:00
|
|
|
},
|
|
|
|
|
required: false,
|
|
|
|
|
})
|
|
|
|
|
skipSslVerify: boolean;
|
|
|
|
|
|
2024-11-26 15:13:57 +08:00
|
|
|
async send(body: NotificationBody) {
|
|
|
|
|
if (!this.webhook) {
|
2026-05-31 01:41:33 +08:00
|
|
|
throw new Error("token不能为空");
|
2024-11-26 15:13:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await this.http.request({
|
|
|
|
|
url: this.webhook,
|
2026-05-31 01:41:33 +08:00
|
|
|
method: "POST",
|
2024-11-26 15:13:57 +08:00
|
|
|
data: {
|
2024-12-03 10:32:47 +08:00
|
|
|
text: `${body.title}\n${body.content}\n\n[查看详情](${body.url})`,
|
2024-11-26 15:13:57 +08:00
|
|
|
},
|
2024-12-02 14:06:55 +08:00
|
|
|
httpProxy: this.httpsProxy,
|
|
|
|
|
skipSslVerify: this.skipSslVerify,
|
2024-11-26 15:13:57 +08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|