From ceba848bddafda49eeebe2f8b60c754b70c5320c Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Fri, 19 Jun 2026 21:22:07 +1000 Subject: [PATCH] pushover request fixes Implemented truncation on data elements to comply with pushover restrictions. Added a timeout for a request to the pushover api endpoint --- src/features/channel/notifications/pushover.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/features/channel/notifications/pushover.ts b/src/features/channel/notifications/pushover.ts index 74f484e6..4d4c9524 100644 --- a/src/features/channel/notifications/pushover.ts +++ b/src/features/channel/notifications/pushover.ts @@ -12,13 +12,16 @@ export async function sendPushover( const {pushoverUserKey, pushoverApiToken, pushoverDevice} = config; const priority = parseInt(config.pushoverPriority ?? "0", 10); + const rawTitle = `[${payload.level.toUpperCase()}] ${payload.title}`; + const rawMessage = payload.data + ? `${payload.message}\n\nData:\n${JSON.stringify(payload.data)}` + : payload.message; + const body: Record = { token: pushoverApiToken, user: pushoverUserKey, - title: `[${payload.level.toUpperCase()}] ${payload.title}`, - message: payload.data - ? `${payload.message}\n\nData:\n${JSON.stringify(payload.data, null, 2)}` - : payload.message, + title: rawTitle.length > 250 ? rawTitle.slice(0, 249) + "…" : rawTitle, + message: rawMessage.length > 1024 ? rawMessage.slice(0, 1023) + "…" : rawMessage, priority, }; @@ -36,6 +39,7 @@ export async function sendPushover( method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify(body), + signal: AbortSignal.timeout(10_000), }); const json = await res.json().catch(() => null);