mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-10-01 01:25:45 -04:00
Add support for Whapi notification provider (#4323)
Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
parent
937c8a9a7b
commit
822ce5384b
39
server/notification-providers/whapi.js
Normal file
39
server/notification-providers/whapi.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
const NotificationProvider = require("./notification-provider");
|
||||||
|
const axios = require("axios");
|
||||||
|
|
||||||
|
class Whapi extends NotificationProvider {
|
||||||
|
name = "whapi";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||||
|
const okMsg = "Sent Successfully.";
|
||||||
|
|
||||||
|
try {
|
||||||
|
const config = {
|
||||||
|
headers: {
|
||||||
|
"Accept": "application/json",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": "Bearer " + notification.whapiAuthToken,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let data = {
|
||||||
|
"to": notification.whapiRecipient,
|
||||||
|
"body": msg,
|
||||||
|
};
|
||||||
|
|
||||||
|
let url = (notification.whapiApiUrl || "https://gate.whapi.cloud/").replace(/\/+$/, "") + "/messages/text";
|
||||||
|
|
||||||
|
await axios.post(url, data, config);
|
||||||
|
|
||||||
|
return okMsg;
|
||||||
|
} catch (error) {
|
||||||
|
this.throwGeneralAxiosError(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Whapi;
|
@ -56,6 +56,7 @@ const GoAlert = require("./notification-providers/goalert");
|
|||||||
const SMSManager = require("./notification-providers/smsmanager");
|
const SMSManager = require("./notification-providers/smsmanager");
|
||||||
const ServerChan = require("./notification-providers/serverchan");
|
const ServerChan = require("./notification-providers/serverchan");
|
||||||
const ZohoCliq = require("./notification-providers/zoho-cliq");
|
const ZohoCliq = require("./notification-providers/zoho-cliq");
|
||||||
|
const Whapi = require("./notification-providers/whapi");
|
||||||
const GtxMessaging = require("./notification-providers/gtx-messaging");
|
const GtxMessaging = require("./notification-providers/gtx-messaging");
|
||||||
const Cellsynt = require("./notification-providers/cellsynt");
|
const Cellsynt = require("./notification-providers/cellsynt");
|
||||||
|
|
||||||
@ -131,6 +132,7 @@ class Notification {
|
|||||||
new WeCom(),
|
new WeCom(),
|
||||||
new GoAlert(),
|
new GoAlert(),
|
||||||
new ZohoCliq(),
|
new ZohoCliq(),
|
||||||
|
new Whapi(),
|
||||||
new GtxMessaging(),
|
new GtxMessaging(),
|
||||||
new Cellsynt(),
|
new Cellsynt(),
|
||||||
];
|
];
|
||||||
|
@ -154,8 +154,9 @@ export default {
|
|||||||
"webhook": "Webhook",
|
"webhook": "Webhook",
|
||||||
"GoAlert": "GoAlert",
|
"GoAlert": "GoAlert",
|
||||||
"ZohoCliq": "ZohoCliq",
|
"ZohoCliq": "ZohoCliq",
|
||||||
|
"whapi": "WhatsApp (Whapi)",
|
||||||
"gtxmessaging": "GtxMessaging",
|
"gtxmessaging": "GtxMessaging",
|
||||||
"Cellsynt": "Cellsynt"
|
"Cellsynt": "Cellsynt",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Put notifications here if it's not supported in most regions or its documentation is not in English
|
// Put notifications here if it's not supported in most regions or its documentation is not in English
|
||||||
|
33
src/components/notifications/Whapi.vue
Normal file
33
src/components/notifications/Whapi.vue
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<template>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="whapi-api-url" class="form-label">{{ $t("API URL") }}</label>
|
||||||
|
<input id="whapi-api-url" v-model="$parent.notification.whapiApiUrl" placeholder="https://gate.whapi.cloud/" type="text" class="form-control">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="whapi-auth-token" class="form-label">{{ $t("Token") }}</label>
|
||||||
|
<HiddenInput id="whapi-auth-token" v-model="$parent.notification.whapiAuthToken" :required="true" autocomplete="new-password"></HiddenInput>
|
||||||
|
<i18n-t tag="div" keypath="wayToGetWhapiUrlAndToken" class="form-text">
|
||||||
|
<a href="https://panel.whapi.cloud/dashboard" target="_blank">https://panel.whapi.cloud/dashboard</a>
|
||||||
|
</i18n-t>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="whapi-recipient" class="form-label">{{ $t("whapiRecipient") }}</label>
|
||||||
|
<input id="whapi-recipient" v-model="$parent.notification.whapiRecipient" type="text" pattern="^[\d-]{10,31}(@[\w\.]{1,})?$" class="form-control" required>
|
||||||
|
<div class="form-text">{{ $t("wayToWriteWhapiRecipient", ["00117612345678", "00117612345678@s.whatsapp.net", "123456789012345678@g.us"]) }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<i18n-t tag="div" keypath="More info on:" class="mb-3 form-text">
|
||||||
|
<a href="https://whapi.cloud/" target="_blank">https://whapi.cloud/</a>
|
||||||
|
</i18n-t>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import HiddenInput from "../HiddenInput.vue";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
HiddenInput,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -55,6 +55,7 @@ import WeCom from "./WeCom.vue";
|
|||||||
import GoAlert from "./GoAlert.vue";
|
import GoAlert from "./GoAlert.vue";
|
||||||
import ZohoCliq from "./ZohoCliq.vue";
|
import ZohoCliq from "./ZohoCliq.vue";
|
||||||
import Splunk from "./Splunk.vue";
|
import Splunk from "./Splunk.vue";
|
||||||
|
import Whapi from "./Whapi.vue";
|
||||||
import Cellsynt from "./Cellsynt.vue";
|
import Cellsynt from "./Cellsynt.vue";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -118,6 +119,7 @@ const NotificationFormList = {
|
|||||||
"GoAlert": GoAlert,
|
"GoAlert": GoAlert,
|
||||||
"ServerChan": ServerChan,
|
"ServerChan": ServerChan,
|
||||||
"ZohoCliq": ZohoCliq,
|
"ZohoCliq": ZohoCliq,
|
||||||
|
"whapi": Whapi,
|
||||||
"gtxmessaging": GtxMessaging,
|
"gtxmessaging": GtxMessaging,
|
||||||
"Cellsynt": Cellsynt,
|
"Cellsynt": Cellsynt,
|
||||||
};
|
};
|
||||||
|
@ -885,6 +885,10 @@
|
|||||||
"deleteRemoteBrowserMessage": "Are you sure want to delete this Remote Browser for all monitors?",
|
"deleteRemoteBrowserMessage": "Are you sure want to delete this Remote Browser for all monitors?",
|
||||||
"GrafanaOncallUrl": "Grafana Oncall URL",
|
"GrafanaOncallUrl": "Grafana Oncall URL",
|
||||||
"Browser Screenshot": "Browser Screenshot",
|
"Browser Screenshot": "Browser Screenshot",
|
||||||
|
"wayToWriteWhapiRecipient": "The phone number with the international prefix, but without the plus sign at the start ({0}), the Contact ID ({1}) or the Group ID ({2}).",
|
||||||
|
"wayToGetWhapiUrlAndToken": "You can get the API URL and the token by going into your desired channel from {0}",
|
||||||
|
"whapiRecipient": "Phone Number / Contact ID / Group ID",
|
||||||
|
"API URL": "API URL",
|
||||||
"What is a Remote Browser?": "What is a Remote Browser?",
|
"What is a Remote Browser?": "What is a Remote Browser?",
|
||||||
"wayToGetHeiiOnCallDetails": "How to get the Trigger ID and API Keys is explained in the {documentation}",
|
"wayToGetHeiiOnCallDetails": "How to get the Trigger ID and API Keys is explained in the {documentation}",
|
||||||
"documentationOf": "{0} Documentation",
|
"documentationOf": "{0} Documentation",
|
||||||
|
Loading…
Reference in New Issue
Block a user