From 5a1b7b9d6c23ff77c79a7147507f501b96311fb2 Mon Sep 17 00:00:00 2001 From: derek Date: Sun, 15 Jan 2023 14:10:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?test:=20=E6=B5=8B=E8=AF=95=E9=80=9A?= =?UTF-8?q?=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- workflows/utils/notification-kit.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/workflows/utils/notification-kit.ts b/workflows/utils/notification-kit.ts index df6c30a7..03489a23 100644 --- a/workflows/utils/notification-kit.ts +++ b/workflows/utils/notification-kit.ts @@ -109,6 +109,8 @@ export class NotificationKit { */ async pushplus(options: PushPlusOptions) { const token: string | unknown = env.PUSHPLUS_TOKEN; + console.log("pushplus", token); + if (token) { throw new Error("未配置PushPlus Token。"); } @@ -138,6 +140,7 @@ export class NotificationKit { */ async dingtalkWebhook(options: DingTalkOptions) { const url: string | unknown = env.DINGDING_WEBHOOK; + console.log("钉钉", url); if (url) { throw new Error("未配置钉钉Webhook。"); } @@ -157,6 +160,7 @@ export class NotificationKit { */ async wecomWebhook(options: WeComOptions) { const url: string | unknown = env.WEIXIN_WEBHOOK; + console.log("微信", url); if (url) { throw new Error("未配置企业微信Webhook。"); } From aad75fc5f12d1aa66b2327643ee7322ea3b7761a Mon Sep 17 00:00:00 2001 From: derek Date: Sun, 15 Jan 2023 14:16:19 +0800 Subject: [PATCH 2/3] =?UTF-8?q?test:=20=E6=B5=8B=E8=AF=95=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- workflows/utils/notification-kit.ts | 37 ++++++++++++++++++----------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/workflows/utils/notification-kit.ts b/workflows/utils/notification-kit.ts index 03489a23..6f241d90 100644 --- a/workflows/utils/notification-kit.ts +++ b/workflows/utils/notification-kit.ts @@ -27,7 +27,7 @@ export class NotificationKit { pass: env.EMAIL_PASS // generated ethereal password }; - if (!auth.user || !auth.pass) { + if (!auth.user || !auth.pass || auth.user === "" || auth.pass === "") { throw new Error("邮箱功能不可用, 请先配置邮箱用户和密码。"); } @@ -109,9 +109,9 @@ export class NotificationKit { */ async pushplus(options: PushPlusOptions) { const token: string | unknown = env.PUSHPLUS_TOKEN; - console.log("pushplus", token); + console.log("pushplus", !token || token === "", typeof token); - if (token) { + if (!token || token === "") { throw new Error("未配置PushPlus Token。"); } @@ -140,18 +140,27 @@ export class NotificationKit { */ async dingtalkWebhook(options: DingTalkOptions) { const url: string | unknown = env.DINGDING_WEBHOOK; - console.log("钉钉", url); - if (url) { + console.log("钉钉", !url || url === "", typeof url); + if (!url || url === "") { throw new Error("未配置钉钉Webhook。"); } - return axios.post(url as string, { - msgtype: "text", - text: { - content: `${options.title}\n${options.content}` - } - }); - // .then(res => console.log(JSON.stringify(res.data))); + return axios + .post( + url as string, + { + msgtype: "text", + text: { + content: `${options.title}\n${options.content}` + } + }, + { + headers: { + "Content-Type": "application/json" + } + } + ) + .then(res => JSON.stringify(res.data)); } /** @@ -160,8 +169,8 @@ export class NotificationKit { */ async wecomWebhook(options: WeComOptions) { const url: string | unknown = env.WEIXIN_WEBHOOK; - console.log("微信", url); - if (url) { + console.log("微信", !url || url === "", typeof url); + if (!url || url === "") { throw new Error("未配置企业微信Webhook。"); } From d2fc7dd5c7b87d3c5961e0b1b01961ccd331869c Mon Sep 17 00:00:00 2001 From: derek Date: Sun, 15 Jan 2023 14:20:26 +0800 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20=E7=A7=BB=E9=99=A4=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- workflows/utils/notification-kit.ts | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/workflows/utils/notification-kit.ts b/workflows/utils/notification-kit.ts index 6f241d90..3ee6fbdb 100644 --- a/workflows/utils/notification-kit.ts +++ b/workflows/utils/notification-kit.ts @@ -109,8 +109,6 @@ export class NotificationKit { */ async pushplus(options: PushPlusOptions) { const token: string | unknown = env.PUSHPLUS_TOKEN; - console.log("pushplus", !token || token === "", typeof token); - if (!token || token === "") { throw new Error("未配置PushPlus Token。"); } @@ -140,27 +138,16 @@ export class NotificationKit { */ async dingtalkWebhook(options: DingTalkOptions) { const url: string | unknown = env.DINGDING_WEBHOOK; - console.log("钉钉", !url || url === "", typeof url); if (!url || url === "") { throw new Error("未配置钉钉Webhook。"); } - return axios - .post( - url as string, - { - msgtype: "text", - text: { - content: `${options.title}\n${options.content}` - } - }, - { - headers: { - "Content-Type": "application/json" - } - } - ) - .then(res => JSON.stringify(res.data)); + return axios.post(url as string, { + msgtype: "text", + text: { + content: `${options.title}\n${options.content}` + } + }); } /** @@ -169,7 +156,6 @@ export class NotificationKit { */ async wecomWebhook(options: WeComOptions) { const url: string | unknown = env.WEIXIN_WEBHOOK; - console.log("微信", !url || url === "", typeof url); if (!url || url === "") { throw new Error("未配置企业微信Webhook。"); }