Skip to content

Commit

Permalink
test: 测试通知推送
Browse files Browse the repository at this point in the history
  • Loading branch information
iDerekLi committed Jan 15, 2023
1 parent 5a1b7b9 commit aad75fc
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions workflows/utils/notification-kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("邮箱功能不可用, 请先配置邮箱用户和密码。");
}

Expand Down Expand Up @@ -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。");
}

Expand Down Expand Up @@ -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));
}

/**
Expand All @@ -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。");
}

Expand Down

0 comments on commit aad75fc

Please sign in to comment.