mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
* feat: notifications backend & creation * feat: assign notification to backup schedule * refactor: status dot one component * chore(notification-details): remove refetchInterval
29 lines
740 B
TypeScript
29 lines
740 B
TypeScript
import type { NotificationConfig } from "~/schemas/notifications";
|
|
|
|
export function buildNtfyShoutrrrUrl(config: Extract<NotificationConfig, { type: "ntfy" }>): string {
|
|
let shoutrrrUrl: string;
|
|
|
|
if (config.serverUrl) {
|
|
const url = new URL(config.serverUrl);
|
|
const hostname = url.hostname;
|
|
const port = url.port ? `:${url.port}` : "";
|
|
shoutrrrUrl = `ntfy://${hostname}${port}/${config.topic}`;
|
|
} else {
|
|
shoutrrrUrl = `ntfy://ntfy.sh/${config.topic}`;
|
|
}
|
|
|
|
const params = new URLSearchParams();
|
|
if (config.token) {
|
|
params.append("token", config.token);
|
|
}
|
|
if (config.priority) {
|
|
params.append("priority", config.priority);
|
|
}
|
|
|
|
if (params.toString()) {
|
|
shoutrrrUrl += `?${params.toString()}`;
|
|
}
|
|
|
|
return shoutrrrUrl;
|
|
}
|