mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-11 08:04:17 -08:00
Merge pull request #650 from xjoker/master
Add Feishu as notification provider
This commit is contained in:
commit
b558708be2
83
server/notification-providers/feishu.js
Normal file
83
server/notification-providers/feishu.js
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
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;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (heartbeatJSON == null) {
|
||||||
|
let testdata = {
|
||||||
|
msg_type: "text",
|
||||||
|
content: {
|
||||||
|
text: msg,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
await axios.post(feishuWebHookUrl, testdata);
|
||||||
|
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;
|
|
@ -18,6 +18,7 @@ const SMTP = require("./notification-providers/smtp");
|
||||||
const Teams = require("./notification-providers/teams");
|
const Teams = require("./notification-providers/teams");
|
||||||
const Telegram = require("./notification-providers/telegram");
|
const Telegram = require("./notification-providers/telegram");
|
||||||
const Webhook = require("./notification-providers/webhook");
|
const Webhook = require("./notification-providers/webhook");
|
||||||
|
const Feishu = require("./notification-providers/feishu");
|
||||||
|
|
||||||
class Notification {
|
class Notification {
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ class Notification {
|
||||||
new Gotify(),
|
new Gotify(),
|
||||||
new Line(),
|
new Line(),
|
||||||
new LunaSea(),
|
new LunaSea(),
|
||||||
|
new Feishu(),
|
||||||
new Mattermost(),
|
new Mattermost(),
|
||||||
new Matrix(),
|
new Matrix(),
|
||||||
new Octopush(),
|
new Octopush(),
|
||||||
|
|
15
src/components/notifications/Feishu.vue
Normal file
15
src/components/notifications/Feishu.vue
Normal file
|
@ -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>
|
|
@ -12,6 +12,7 @@ import Pushy from "./Pushy.vue";
|
||||||
import Octopush from "./Octopush.vue";
|
import Octopush from "./Octopush.vue";
|
||||||
import PromoSMS from "./PromoSMS.vue";
|
import PromoSMS from "./PromoSMS.vue";
|
||||||
import LunaSea from "./LunaSea.vue";
|
import LunaSea from "./LunaSea.vue";
|
||||||
|
import Feishu from "./Feishu.vue";
|
||||||
import Apprise from "./Apprise.vue";
|
import Apprise from "./Apprise.vue";
|
||||||
import Pushbullet from "./Pushbullet.vue";
|
import Pushbullet from "./Pushbullet.vue";
|
||||||
import Line from "./Line.vue";
|
import Line from "./Line.vue";
|
||||||
|
@ -38,6 +39,7 @@ const NotificationFormList = {
|
||||||
"octopush": Octopush,
|
"octopush": Octopush,
|
||||||
"promosms": PromoSMS,
|
"promosms": PromoSMS,
|
||||||
"lunasea": LunaSea,
|
"lunasea": LunaSea,
|
||||||
|
"Feishu": Feishu,
|
||||||
"apprise": Apprise,
|
"apprise": Apprise,
|
||||||
"pushbullet": Pushbullet,
|
"pushbullet": Pushbullet,
|
||||||
"line": Line,
|
"line": Line,
|
||||||
|
|
|
@ -280,5 +280,6 @@ export default {
|
||||||
promosmsTypeSpeed: "SMS SPEED - Highest priority in system. Very quick and reliable but costly (about twice of SMS FULL price).",
|
promosmsTypeSpeed: "SMS SPEED - Highest priority in system. Very quick and reliable but costly (about twice of SMS FULL price).",
|
||||||
promosmsPhoneNumber: "Phone number (for Polish recipient You can skip area codes)",
|
promosmsPhoneNumber: "Phone number (for Polish recipient You can skip area codes)",
|
||||||
promosmsSMSSender: "SMS Sender Name : Pre-registred name or one of defaults: InfoSMS, SMS Info, MaxSMS, INFO, SMS",
|
promosmsSMSSender: "SMS Sender Name : Pre-registred name or one of defaults: InfoSMS, SMS Info, MaxSMS, INFO, SMS",
|
||||||
|
"Feishu WebHookUrl": "Feishu WebHookUrl",
|
||||||
// End notification form
|
// End notification form
|
||||||
};
|
};
|
||||||
|
|
|
@ -198,4 +198,5 @@ export default {
|
||||||
pushbullet: "Pushbullet",
|
pushbullet: "Pushbullet",
|
||||||
line: "Line Messenger",
|
line: "Line Messenger",
|
||||||
mattermost: "Mattermost",
|
mattermost: "Mattermost",
|
||||||
|
"Feishu WebHookUrl": "飞书 WebHook 地址",
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue