feat: update notification handling to make accessToken optional

- Modified the notification schema to allow accessToken to be optional, enhancing flexibility in notification settings.
- Updated related components and database schema to accommodate the change, ensuring backward compatibility.
- Improved handling of accessToken in notification requests and responses, defaulting to null when not provided.
This commit is contained in:
Mauricio Siu
2025-12-01 00:44:53 -06:00
parent 9e98f9ce7f
commit 6b346d30ee
7 changed files with 6864 additions and 16 deletions

View File

@@ -156,15 +156,20 @@ 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: {
Authorization: `Bearer ${connection.accessToken}`,
"X-Priority": connection.priority?.toString() || "3",
"X-Title": title,
"X-Tags": tags,
"X-Actions": actions,
},
headers,
body: message,
});