feat(notifications): implement gotify provider

This commit is contained in:
depado
2025-01-10 20:07:43 +01:00
parent ad479c4be1
commit cc473b3e87
8 changed files with 1232 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ import type {
email,
slack,
telegram,
gotify,
} from "@dokploy/server/db/schema";
import nodemailer from "nodemailer";
@@ -87,3 +88,31 @@ export const sendSlackNotification = async (
console.log(err);
}
};
export const sendGotifyNotification = async (
connection: typeof gotify.$inferInsert,
title: string,
message: string,
) => {
const response = await fetch(`${connection.serverUrl}/message`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Gotify-Key": connection.appToken,
},
body: JSON.stringify({
title: title,
message: message,
priority: connection.priority,
extras: {
"client::display": {
"contentType": "text/plain"
}
}
}),
});
if (!response.ok) {
throw new Error(`Failed to send Gotify notification: ${response.statusText}`);
}
};