Files
zerobyte/app/server/utils/shoutrrr.ts
Nico 332e5bffda refactor: extract restic in core package (#651)
* refactor: extract restic in core package

* chore: add turbo task runner

* refactor: split server utils

* chore: simplify withDeps signature and fix non-null assertion
2026-03-11 21:56:07 +01:00

41 lines
1.1 KiB
TypeScript

import { safeExec } from "@zerobyte/core/node";
import { logger } from "@zerobyte/core/node";
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 safeExec({ 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,
};
}
}