6 changed files with 108 additions and 0 deletions
			
			
		| @ -0,0 +1,87 @@ | |||
| const NotificationProvider = require("./notification-provider"); | |||
| const axios = require("axios"); | |||
| const { DOWN, UP } = require("../../src/util"); | |||
| 
 | |||
| class Feishu extends NotificationProvider { | |||
|     name = "Feishu"; | |||
| 
 | |||
|     async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { | |||
|         let okMsg = "Sent Successfully."; | |||
|         let feishuWebHookUrl = notification.feishuWebHookUrl; | |||
| 
 | |||
|         console.log(heartbeatJSON); | |||
|         try { | |||
|             if (heartbeatJSON == null) { | |||
|                 let testdata = { | |||
|                     msg_type: "text", | |||
|                     content: { | |||
|                         text: "Testing Successful.", | |||
|                     }, | |||
|                 }; | |||
|                 var t = await axios.post(feishuWebHookUrl, testdata); | |||
|                 console.log(t); | |||
|                 return okMsg; | |||
|             } | |||
| 
 | |||
|             if (heartbeatJSON["status"] == DOWN) { | |||
|                 let downdata = { | |||
|                     msg_type: "post", | |||
|                     content: { | |||
|                         post: { | |||
|                             zh_cn: { | |||
|                                 title: | |||
|                                     "UptimeKuma Alert: " + monitorJSON["name"], | |||
|                                 content: [ | |||
|                                     [ | |||
|                                         { | |||
|                                             tag: "text", | |||
|                                             text: | |||
|                                                 "[Down] " + | |||
|                                                 heartbeatJSON["msg"] + | |||
|                                                 "\nTime (UTC): " + | |||
|                                                 heartbeatJSON["time"], | |||
|                                         }, | |||
|                                     ], | |||
|                                 ], | |||
|                             }, | |||
|                         }, | |||
|                     }, | |||
|                 }; | |||
|                 await axios.post(feishuWebHookUrl, downdata); | |||
|                 return okMsg; | |||
|             } | |||
| 
 | |||
|             if (heartbeatJSON["status"] == UP) { | |||
|                 let updata = { | |||
|                     msg_type: "post", | |||
|                     content: { | |||
|                         post: { | |||
|                             zh_cn: { | |||
|                                 title: | |||
|                                     "UptimeKuma Alert: " + monitorJSON["name"], | |||
|                                 content: [ | |||
|                                     [ | |||
|                                         { | |||
|                                             tag: "text", | |||
|                                             text: | |||
|                                                 "[Up] " + | |||
|                                                 heartbeatJSON["msg"] + | |||
|                                                 "\nTime (UTC): " + | |||
|                                                 heartbeatJSON["time"], | |||
|                                         }, | |||
|                                     ], | |||
|                                 ], | |||
|                             }, | |||
|                         }, | |||
|                     }, | |||
|                 }; | |||
|                 await axios.post(feishuWebHookUrl, updata); | |||
|                 return okMsg; | |||
|             } | |||
|         } catch (error) { | |||
|             this.throwGeneralAxiosError(error); | |||
|         } | |||
|     } | |||
| } | |||
| 
 | |||
| module.exports = Feishu; | |||
| @ -0,0 +1,15 @@ | |||
| <template> | |||
|     <div class="mb-3"> | |||
|         <label for="Feishu-WebHookUrl" class="form-label">{{ $t("Feishu WebHookUrl") }}<span style="color: red;"><sup>*</sup></span></label> | |||
|         <input id="Feishu-WebHookUrl" v-model="$parent.notification.feishuWebHookUrl" type="text" class="form-control" required> | |||
|         <div class="form-text"> | |||
|             <p><span style="color: red;"><sup>*</sup></span>{{ $t("Required") }}</p> | |||
|         </div> | |||
|           <i18n-t tag="div" keypath="wayToGetTeamsURL" class="form-text"> | |||
|             <a | |||
|                 href="https://www.feishu.cn/hc/zh-CN/articles/360024984973" | |||
|                 target="_blank" | |||
|             >{{ $t("here") }}</a> | |||
|         </i18n-t> | |||
|     </div> | |||
| </template> | |||
					Loading…
					
					
				
		Reference in new issue