Skip to content

Commit

Permalink
Add Gotify as notification option
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyao2333 committed Oct 19, 2024
1 parent 75b0413 commit 6ce021f
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/helpers/notifme.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import axios from "axios";
import type { Channel } from "notifme-sdk";
import NotifmeSdk, { EmailProvider, SlackProvider, SmsProvider } from "notifme-sdk";
import { replaceEnvironmentVariables } from "./environment";
import { getSecret } from "./secrets";
import type {Channel} from "notifme-sdk";
import NotifmeSdk, {EmailProvider, SlackProvider, SmsProvider} from "notifme-sdk";
import {replaceEnvironmentVariables} from "./environment";
import {getSecret} from "./secrets";

const channels: {
email?: Channel<EmailProvider>;
Expand Down Expand Up @@ -410,4 +410,18 @@ export const sendNotification = async (message: string) => {
}
console.log("Finished sending Webhook");
}
if (getSecret("NOTIFICATION_GOTIFY")) {
console.log("Sending Gotify");
try {
await axios.post(`${getSecret("NOTIFICATION_GOTIFY_URL")}/message?token=${getSecret("NOTIFICATION_GOTIFY_TOKEN")}`, {
message: message,
title: (getSecret("NOTIFICATION_GOTIFY_TITLE") || "Upptime"),
priority: (getSecret("NOTIFICATION_GOTIFY_PRIORITY") || 5),
});
console.log("Success Gotify");
} catch (error) {
console.log("Got an error", error);
}
console.log("Finished sending Gotify");
}
};

0 comments on commit 6ce021f

Please sign in to comment.