From f51156f18e2031631bfd8163264c0b0e6f407298 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Thu, 14 Oct 2021 16:24:03 +0800 Subject: [PATCH] run eslint for #687 --- server/notification-providers/aliyun-sms.js | 24 ++++++++++----------- server/notification-providers/dingding.js | 18 ++++++++-------- src/components/notifications/AliyunSms.vue | 2 +- src/components/notifications/DingDing.vue | 2 +- src/components/notifications/Feishu.vue | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/server/notification-providers/aliyun-sms.js b/server/notification-providers/aliyun-sms.js index d5d59be9..6a206320 100644 --- a/server/notification-providers/aliyun-sms.js +++ b/server/notification-providers/aliyun-sms.js @@ -12,7 +12,7 @@ class AliyunSMS extends NotificationProvider { try { if (heartbeatJSON != null) { - var msgBody = JSON.stringify({ + let msgBody = JSON.stringify({ name: monitorJSON["name"], time: heartbeatJSON["time"], status: this.statusToString(heartbeatJSON["status"]), @@ -22,7 +22,7 @@ class AliyunSMS extends NotificationProvider { return okMsg; } } else { - var msgBody = JSON.stringify({ + let msgBody = JSON.stringify({ name: "", time: "", status: "", @@ -38,7 +38,7 @@ class AliyunSMS extends NotificationProvider { } async sendSms(notification, msgbody) { - var params = { + let params = { PhoneNumbers: notification.phonenumber, TemplateCode: notification.templateCode, SignName: notification.signName, @@ -54,7 +54,7 @@ class AliyunSMS extends NotificationProvider { }; params.Signature = this.sign(params, notification.secretAccessKey); - var config = { + let config = { method: "POST", url: "http://dysmsapi.aliyuncs.com/", headers: { @@ -63,7 +63,7 @@ class AliyunSMS extends NotificationProvider { data: qs.stringify(params), }; - var result = await axios(config); + let result = await axios(config); if (result.data.Message == "OK") { return true; } @@ -72,21 +72,21 @@ class AliyunSMS extends NotificationProvider { /** Aliyun request sign */ sign(param, AccessKeySecret) { - var param2 = {}, - data = []; + let param2 = {}; + let data = []; - var oa = Object.keys(param).sort(); + let oa = Object.keys(param).sort(); - for (var i = 0; i < oa.length; i++) { - var key = oa[i]; + for (let i = 0; i < oa.length; i++) { + let key = oa[i]; param2[key] = param[key]; } - for (var key in param2) { + for (let key in param2) { data.push(`${encodeURIComponent(key)}=${encodeURIComponent(param2[key])}`); } - var StringToSign = `POST&${encodeURIComponent("/")}&${encodeURIComponent(data.join("&"))}`; + let StringToSign = `POST&${encodeURIComponent("/")}&${encodeURIComponent(data.join("&"))}`; return Crypto .createHmac("sha1", `${AccessKeySecret}&`) .update(Buffer.from(StringToSign)) diff --git a/server/notification-providers/dingding.js b/server/notification-providers/dingding.js index 1dd52a52..f099192d 100644 --- a/server/notification-providers/dingding.js +++ b/server/notification-providers/dingding.js @@ -11,7 +11,7 @@ class DingDing extends NotificationProvider { try { if (heartbeatJSON != null) { - var params = { + let params = { msgtype: "markdown", markdown: { title: monitorJSON["name"], @@ -22,10 +22,10 @@ class DingDing extends NotificationProvider { return okMsg; } } else { - var params = { + let params = { msgtype: "text", text: { - content:msg + content: msg } }; if (this.sendToDingDing(notification, params)) { @@ -38,9 +38,9 @@ class DingDing extends NotificationProvider { } async sendToDingDing(notification, params) { - var timestamp=Date.now() + let timestamp = Date.now(); - var config = { + let config = { method: "POST", headers: { "Content-Type": "application/json", @@ -49,7 +49,7 @@ class DingDing extends NotificationProvider { data: JSON.stringify(params), }; - var result = await axios(config); + let result = await axios(config); if (result.data.errmsg == "ok") { return true; } @@ -57,10 +57,10 @@ class DingDing extends NotificationProvider { } /** DingDing sign */ - sign(timestamp,secretKey) { + sign(timestamp, secretKey) { return Crypto - .createHmac("sha256", Buffer.from(secretKey, 'utf8')) - .update(Buffer.from(`${timestamp}\n${secretKey}`, 'utf8')) + .createHmac("sha256", Buffer.from(secretKey, "utf8")) + .update(Buffer.from(`${timestamp}\n${secretKey}`, "utf8")) .digest("base64"); } diff --git a/src/components/notifications/AliyunSms.vue b/src/components/notifications/AliyunSms.vue index 3f65b346..2c25a3a9 100644 --- a/src/components/notifications/AliyunSms.vue +++ b/src/components/notifications/AliyunSms.vue @@ -15,7 +15,7 @@ -
+

Sms template must contain parameters:
${name} ${time} ${status} ${msg}

https://help.aliyun.com/document_detail/101414.html diff --git a/src/components/notifications/DingDing.vue b/src/components/notifications/DingDing.vue index 3ee475c8..713859ac 100644 --- a/src/components/notifications/DingDing.vue +++ b/src/components/notifications/DingDing.vue @@ -6,7 +6,7 @@ -
+

For safety, must use secret key

https://developers.dingtalk.com/document/robots/custom-robot-access diff --git a/src/components/notifications/Feishu.vue b/src/components/notifications/Feishu.vue index 18dc2642..6e00a314 100644 --- a/src/components/notifications/Feishu.vue +++ b/src/components/notifications/Feishu.vue @@ -5,7 +5,7 @@

*{{ $t("Required") }}

- +