mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-20 05:15:23 +02:00
feat(notification): add ntfy notifications
This commit is contained in:
@@ -2,6 +2,7 @@ import type {
|
||||
discord,
|
||||
email,
|
||||
gotify,
|
||||
ntfy,
|
||||
slack,
|
||||
telegram,
|
||||
} from "@dokploy/server/db/schema";
|
||||
@@ -126,3 +127,27 @@ export const sendGotifyNotification = async (
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const sendNtfyNotification = async (
|
||||
connection: typeof ntfy.$inferInsert,
|
||||
title: string,
|
||||
tags: string,
|
||||
actions: string,
|
||||
message: string,
|
||||
) => {
|
||||
const response = await fetch(`${connection.serverUrl}/${connection.topic}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${connection.accessToken}`,
|
||||
"X-Priority": connection.priority?.toString() || "3",
|
||||
"X-Title": title,
|
||||
"X-Tags": tags,
|
||||
"X-Actions": actions,
|
||||
},
|
||||
body: message,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to send ntfy notification: ${response.statusText}`);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user