feat(FN-4078): add ntfy access token support to notifications

Adds ntfy access token support to Fusion's notification system, wiring the token through the core settings schema, dashboard UI (SettingsModal), engine notifier, and notification pipeline, with corresponding tests across core, dashboard, and engine packages; also updates settings and storage documen

Fusion-Task-Id: FN-4078
This commit is contained in:
Fusion
2026-05-12 07:05:43 -07:00
committed by gsxdsm
parent bbc9111ff6
commit 7ca8d5ab50
17 changed files with 312 additions and 15 deletions

View File

@@ -1850,16 +1850,31 @@ export function registerSettingsMemoryRoutes(ctx: ApiRoutesContext, deps: Settin
const storedServer = typeof settings.ntfyBaseUrl === "string" && settings.ntfyBaseUrl.trim()
? normalizeNtfyBaseUrl(settings.ntfyBaseUrl, "settings")
: undefined;
const tokenOverride = req.body?.ntfyAccessToken;
if (tokenOverride !== undefined && tokenOverride !== null && typeof tokenOverride !== "string") {
throw badRequest("ntfy access token must be a string");
}
const requestToken = typeof tokenOverride === "string" && tokenOverride.trim()
? tokenOverride.trim()
: undefined;
const storedToken = typeof settings.ntfyAccessToken === "string" && settings.ntfyAccessToken.trim()
? settings.ntfyAccessToken.trim()
: undefined;
const ntfyBaseUrl = requestOverride ?? storedServer ?? "https://ntfy.sh";
const url = `${ntfyBaseUrl}/${topic}`;
const headers: Record<string, string> = {
"Title": "Fusion test notification",
"Priority": "default",
"Content-Type": "text/plain",
};
const ntfyAccessToken = requestToken ?? storedToken;
if (ntfyAccessToken) {
headers.Authorization = `Bearer ${ntfyAccessToken}`;
}
const response = await fetch(url, {
method: "POST",
headers: {
"Title": "Fusion test notification",
"Priority": "default",
"Content-Type": "text/plain",
},
headers,
body: "Fusion test notification — your notifications are working!",
});
@@ -1976,16 +1991,31 @@ export function registerSettingsMemoryRoutes(ctx: ApiRoutesContext, deps: Settin
const storedServer = typeof settings.ntfyBaseUrl === "string" && settings.ntfyBaseUrl.trim()
? normalizeNtfyBaseUrl(settings.ntfyBaseUrl, "settings")
: undefined;
const tokenOverride = config.ntfyAccessToken ?? body.ntfyAccessToken;
if (tokenOverride !== undefined && tokenOverride !== null && typeof tokenOverride !== "string") {
throw badRequest("ntfy access token must be a string");
}
const requestToken = typeof tokenOverride === "string" && tokenOverride.trim()
? tokenOverride.trim()
: undefined;
const storedToken = typeof settings.ntfyAccessToken === "string" && settings.ntfyAccessToken.trim()
? settings.ntfyAccessToken.trim()
: undefined;
const ntfyBaseUrl = requestOverride ?? storedServer ?? "https://ntfy.sh";
const url = `${ntfyBaseUrl}/${topic}`;
const headers: Record<string, string> = {
"Title": "Fusion test notification",
"Priority": "default",
"Content-Type": "text/plain",
};
const ntfyAccessToken = requestToken ?? storedToken;
if (ntfyAccessToken) {
headers.Authorization = `Bearer ${ntfyAccessToken}`;
}
const response = await fetch(url, {
method: "POST",
headers: {
"Title": "Fusion test notification",
"Priority": "default",
"Content-Type": "text/plain",
},
headers,
body: "Fusion test notification — your notifications are working!",
});