mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-30 03:25:22 +02:00
refactor: streamline notification header construction in sendNtfyNotification
- Consolidated header creation for the notification request, improving code readability and maintainability. - Made the Authorization header conditional based on the presence of accessToken, enhancing flexibility.
This commit is contained in:
@@ -156,20 +156,17 @@ export const sendNtfyNotification = async (
|
||||
actions: string,
|
||||
message: string,
|
||||
) => {
|
||||
const headers: Record<string, string> = {
|
||||
"X-Priority": connection.priority?.toString() || "3",
|
||||
"X-Title": title,
|
||||
"X-Tags": tags,
|
||||
"X-Actions": actions,
|
||||
};
|
||||
|
||||
if (connection.accessToken) {
|
||||
headers.Authorization = `Bearer ${connection.accessToken}`;
|
||||
}
|
||||
|
||||
const response = await fetch(`${connection.serverUrl}/${connection.topic}`, {
|
||||
method: "POST",
|
||||
headers,
|
||||
headers: {
|
||||
...(connection.accessToken && {
|
||||
Authorization: `Bearer ${connection.accessToken}`,
|
||||
}),
|
||||
"X-Priority": connection.priority?.toString() || "3",
|
||||
"X-Title": title,
|
||||
"X-Tags": tags,
|
||||
"X-Actions": actions,
|
||||
},
|
||||
body: message,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user