mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat(notifications): implement gotify provider
This commit is contained in:
@@ -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}`);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user