mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
fix(ntfy): wrong usage of token
This commit is contained in:
@@ -49,8 +49,9 @@ export const ntfyNotificationConfigSchema = type({
|
|||||||
type: "'ntfy'",
|
type: "'ntfy'",
|
||||||
serverUrl: "string?",
|
serverUrl: "string?",
|
||||||
topic: "string",
|
topic: "string",
|
||||||
token: "string?",
|
|
||||||
priority: "'max' | 'high' | 'default' | 'low' | 'min'",
|
priority: "'max' | 'high' | 'default' | 'low' | 'min'",
|
||||||
|
username: "string?",
|
||||||
|
password: "string?",
|
||||||
});
|
});
|
||||||
|
|
||||||
export const pushoverNotificationConfigSchema = type({
|
export const pushoverNotificationConfigSchema = type({
|
||||||
|
|||||||
@@ -3,19 +3,26 @@ import type { NotificationConfig } from "~/schemas/notifications";
|
|||||||
export function buildNtfyShoutrrrUrl(config: Extract<NotificationConfig, { type: "ntfy" }>): string {
|
export function buildNtfyShoutrrrUrl(config: Extract<NotificationConfig, { type: "ntfy" }>): string {
|
||||||
let shoutrrrUrl: string;
|
let shoutrrrUrl: string;
|
||||||
|
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
|
const auth =
|
||||||
|
config.username && config.password
|
||||||
|
? `${encodeURIComponent(config.username)}:${encodeURIComponent(config.password)}@`
|
||||||
|
: "";
|
||||||
|
|
||||||
if (config.serverUrl) {
|
if (config.serverUrl) {
|
||||||
const url = new URL(config.serverUrl);
|
const url = new URL(config.serverUrl);
|
||||||
const hostname = url.hostname;
|
const hostname = url.hostname;
|
||||||
const port = url.port ? `:${url.port}` : "";
|
const port = url.port ? `:${url.port}` : "";
|
||||||
shoutrrrUrl = `ntfy://${hostname}${port}/${config.topic}`;
|
const scheme = url.protocol === "https:" ? "https" : "http";
|
||||||
|
|
||||||
|
params.append("scheme", scheme);
|
||||||
|
|
||||||
|
shoutrrrUrl = `ntfy://${auth}${hostname}${port}/${config.topic}`;
|
||||||
} else {
|
} else {
|
||||||
shoutrrrUrl = `ntfy://ntfy.sh/${config.topic}`;
|
shoutrrrUrl = `ntfy://${auth}ntfy.sh/${config.topic}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = new URLSearchParams();
|
|
||||||
if (config.token) {
|
|
||||||
params.append("token", config.token);
|
|
||||||
}
|
|
||||||
if (config.priority) {
|
if (config.priority) {
|
||||||
params.append("priority", config.priority);
|
params.append("priority", config.priority);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user