mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-27 05:58:46 +00: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,
|
actions: string,
|
||||||
message: 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}`, {
|
const response = await fetch(`${connection.serverUrl}/${connection.topic}`, {
|
||||||
method: "POST",
|
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,
|
body: message,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user