mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-02-09 04:51:20 -05:00
* feat: add generic webhook form & refactor each type in its own form * chore: pr feedbacks * fix(email-form): filter out empty emails
17 lines
555 B
TypeScript
17 lines
555 B
TypeScript
import type { NotificationConfig } from "~/schemas/notifications";
|
|
|
|
export const buildGotifyShoutrrrUrl = (config: Extract<NotificationConfig, { type: "gotify" }>) => {
|
|
const url = new URL(config.serverUrl);
|
|
const hostname = url.hostname;
|
|
const port = url.port ? `:${url.port}` : "";
|
|
const path = config.path ? `/${config.path.replace(/^\/+|\/+$/g, "")}` : "";
|
|
|
|
let shoutrrrUrl = `gotify://${hostname}${port}${path}/${config.token}`;
|
|
|
|
if (config.priority !== undefined) {
|
|
shoutrrrUrl += `?priority=${config.priority}`;
|
|
}
|
|
|
|
return shoutrrrUrl;
|
|
};
|