Files
zerobyte/app/server/utils/shoutrrr.ts
Nico d3f9ced5dc refactor: use spawn & exec instead of bun $ (#356)
* refactor: use spawn & exec accordingly

* chore: pr feedbacks
2026-01-15 22:09:00 +01:00

41 lines
1.0 KiB
TypeScript

import { exec } from "./spawn";
import { logger } from "./logger";
import { toMessage } from "./errors";
export interface SendNotificationParams {
shoutrrrUrl: string;
title: string;
body: string;
}
export async function sendNotification(params: SendNotificationParams) {
const { shoutrrrUrl, title, body } = params;
try {
const args = ["send", "--url", shoutrrrUrl, "--title", title, "--message", body];
logger.debug(`Sending notification via Shoutrrr: ${title}`);
const result = await exec({ command: "shoutrrr", args });
if (result.exitCode === 0) {
logger.debug(`Notification sent successfully: ${title}`);
return { success: true };
}
const errorMessage = result.stderr || result.stdout || "Unknown error";
logger.error(`Failed to send notification: ${errorMessage}`);
return {
success: false,
error: errorMessage,
};
} catch (error) {
const errorMessage = toMessage(error);
logger.error(`Error sending notification: ${errorMessage}`);
return {
success: false,
error: errorMessage,
};
}
}