forked from louislam/uptime-kuma
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new notification provider
46elks
(louislam#5184)
Co-authored-by: Frank Elsinga <[email protected]>
- Loading branch information
1 parent
bafca6b
commit dda4061
Showing
6 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const NotificationProvider = require("./notification-provider"); | ||
const axios = require("axios"); | ||
|
||
class Elks extends NotificationProvider { | ||
name = "Elks"; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { | ||
const okMsg = "Sent Successfully."; | ||
const url = "https://api.46elks.com/a1/sms"; | ||
|
||
try { | ||
let data = new URLSearchParams(); | ||
data.append("from", notification.elksFromNumber); | ||
data.append("to", notification.elksToNumber ); | ||
data.append("message", msg); | ||
|
||
const config = { | ||
headers: { | ||
"Authorization": "Basic " + Buffer.from(`${notification.elksUsername}:${notification.elksAuthToken}`).toString("base64") | ||
} | ||
}; | ||
|
||
await axios.post(url, data, config); | ||
|
||
return okMsg; | ||
} catch (error) { | ||
this.throwGeneralAxiosError(error); | ||
} | ||
} | ||
} | ||
|
||
module.exports = Elks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template> | ||
<div class="mb-3"> | ||
<label for="ElksUsername" class="form-label">{{ $t("Username") }}</label> | ||
<input id="ElksUsername" v-model="$parent.notification.elksUsername" type="text" class="form-control" required> | ||
<label for="ElksPassword" class="form-label">{{ $t("Password") }}</label> | ||
</div> | ||
<div class="form-text"> | ||
<HiddenInput id="ElksPassword" v-model="$parent.notification.elksAuthToken" :required="true" autocomplete="new-password"></HiddenInput> | ||
<i18n-t tag="p" keypath="Can be found on:"> | ||
<a href="https://46elks.com/account" target="_blank">https://46elks.com/account</a> | ||
</i18n-t> | ||
</div> | ||
<div class="mb-3"> | ||
<label for="Elks-from-number" class="form-label">{{ $t("From") }}</label> | ||
<input id="Elks-from-number" v-model="$parent.notification.elksFromNumber" type="text" class="form-control" required> | ||
<div class="form-text"> | ||
{{ $t("Either a text sender ID or a phone number in E.164 format if you want to be able to receive replies.") }} | ||
<i18n-t tag="p" keypath="More info on:"> | ||
<a href="https://46elks.se/kb/text-sender-id" target="_blank">https://46elks.se/kb/text-sender-id</a> | ||
</i18n-t> | ||
</div> | ||
</div> | ||
|
||
<div class="mb-3"> | ||
<label for="Elks-to-number" class="form-label">{{ $t("To Number") }}</label> | ||
<input id="Elks-to-number" v-model="$parent.notification.elksToNumber" type="text" class="form-control" required> | ||
<div class="form-text"> | ||
{{ $t("The phone number of the recipient in E.164 format.") }} | ||
<i18n-t tag="p" keypath="More info on:"> | ||
<a href="https://46elks.se/kb/e164" target="_blank">https://46elks.se/kb/e164</a> | ||
</i18n-t> | ||
</div> | ||
</div> | ||
|
||
<i18n-t tag="p" keypath="More info on:" style="margin-top: 8px;"> | ||
<a href="https://46elks.com/docs/send-sms" target="_blank">https://46elks.com/docs/send-sms</a> | ||
</i18n-t> | ||
</template> | ||
|
||
<script> | ||
import HiddenInput from "../HiddenInput.vue"; | ||
export default { | ||
components: { | ||
HiddenInput, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters