[READ-ONLY] Mirror of https://github.com/FoxxMD/komodo-utilities. Small utilities to enhance Komodo
gotify komodo
0

Configure Feed

Select the types of activity you want to include in your feed.

feat: Log payloads and Komodo alert data on errors

FoxxMD (Nov 26, 2024, 5:40 PM UTC) 4f3f0e9a 8ce65309

+29 -14
+11 -7
notifiers/gotify/main.ts
··· 53 53 54 54 55 55 const pushAlert = async (title: string, message: string, priority: number): Promise<any> => { 56 + const payload: Parameters<typeof gotify>[0] = { 57 + server: GOTIFY_URL, 58 + app: GOTIFY_APP_TOKEN, 59 + title: title, 60 + message: message, 61 + priority: priority, 62 + }; 56 63 try { 57 - await gotify({ 58 - server: GOTIFY_URL, 59 - app: GOTIFY_APP_TOKEN, 60 - title: title, 61 - message: message, 62 - priority: priority, 63 - }); 64 + await gotify(payload); 64 65 } catch (e) { 66 + console.debug('Gotify Payload', {...payload, app: `XXX...${GOTIFY_APP_TOKEN.substring(GOTIFY_APP_TOKEN.length - 3)}`}); 65 67 throw new Error("Error occurred while trying to push to Gotify", { 66 68 cause: e, 67 69 }); ··· 77 79 try { 78 80 data = parseAlert(alert, {levelInTitle}); 79 81 } catch (e) { 82 + console.debug('Komodo Alert Payload:', alert); 80 83 console.error(e); 81 84 return new Response(); 82 85 } 83 86 84 87 pushAlert(titleAndSubtitle(data), data.message ?? '', severityLevelPriority[alert.level]).catch((e) => { 88 + console.debug('Komodo Alert Payload:', alert); 85 89 console.error( 86 90 new Error("Failed to push Alert to Gotify", { cause: e }), 87 91 );
+18 -7
notifiers/ntfy/main.ts
··· 76 76 } 77 77 78 78 const pushAlert = async (title: string, message: string, priority: number): Promise<any> => { 79 + const req: Config = { 80 + message: message, 81 + topic: NTFY_TOPIC, 82 + title: title, 83 + server: NTFY_URL, 84 + priority: priority, 85 + }; 79 86 try { 80 - const req: Config = { 81 - message: message, 82 - topic: NTFY_TOPIC, 83 - title: title, 84 - server: NTFY_URL, 85 - priority: priority, 86 - }; 87 87 if(NTFY_USER !== undefined && NTFY_PASSWORD !== undefined) { 88 88 req.authorization = { 89 89 username: NTFY_USER, ··· 94 94 } 95 95 await publish(req); 96 96 } catch (e) { 97 + const redacted = req; 98 + if(redacted.authorization !== undefined) { 99 + if(typeof redacted.authorization === 'string') { 100 + redacted.authorization = `XXX${redacted.authorization.substring(redacted.authorization.length - 3)}` 101 + } else { 102 + redacted.authorization.username = `XXX${redacted.authorization.username.substring(redacted.authorization.username.length - 3)}` 103 + redacted.authorization.password = `XXX${redacted.authorization.password.substring(redacted.authorization.password.length - 3)}` 104 + } 105 + } 106 + console.debug('ntfy payload:', redacted); 97 107 throw new Error("Error occurred while trying to push to ntfy", { 98 108 cause: e, 99 109 }); ··· 114 124 } 115 125 116 126 pushAlert(titleAndSubtitle(data), data.message ?? '', severityLevelPriority[alert.level]).catch((e) => { 127 + console.debug('Komodo Alert Payload:', alert); 117 128 console.error( 118 129 new Error("Failed to push Alert to ntfy", { cause: e }), 119 130 );