Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 693922fff1 |
@@ -583,7 +583,7 @@ export async function sendShoutrrrNotification(
|
|||||||
urlStr: string,
|
urlStr: string,
|
||||||
title: string,
|
title: string,
|
||||||
message: string
|
message: string
|
||||||
): Promise<{ success: boolean; error?: string }> {
|
): Promise<{ success: boolean; error?: string; providerMessageId?: string }> {
|
||||||
try {
|
try {
|
||||||
if (urlStr.startsWith("pushover://")) {
|
if (urlStr.startsWith("pushover://")) {
|
||||||
const pushoverAuthority = urlStr.slice("pushover://".length).split("/")[0] ?? "";
|
const pushoverAuthority = urlStr.slice("pushover://".length).split("/")[0] ?? "";
|
||||||
@@ -736,7 +736,7 @@ export async function sendShoutrrrNotification(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use ONLY the reconstructed URL from validation - never the original urlStr
|
// Use ONLY the reconstructed URL from validation - never the original urlStr
|
||||||
const { url: sanitizedUrl, isNtfy: _isNtfy, auth } = validation;
|
const { url: sanitizedUrl, isNtfy, auth } = validation;
|
||||||
|
|
||||||
let targetUrl: string;
|
let targetUrl: string;
|
||||||
const method = "POST";
|
const method = "POST";
|
||||||
@@ -823,7 +823,17 @@ export async function sendShoutrrrNotification(
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
return { success: true };
|
let providerMessageId: string | undefined;
|
||||||
|
if (isNtfy) {
|
||||||
|
try {
|
||||||
|
const payload = (await response.json()) as { id?: unknown };
|
||||||
|
providerMessageId = typeof payload.id === "string" && payload.id.length > 0 ? payload.id : undefined;
|
||||||
|
} catch {
|
||||||
|
providerMessageId = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { success: true, providerMessageId };
|
||||||
} else {
|
} else {
|
||||||
const errorText = await response.text();
|
const errorText = await response.text();
|
||||||
return { success: false, error: `HTTP ${response.status}: ${errorText}` };
|
return { success: false, error: `HTTP ${response.status}: ${errorText}` };
|
||||||
|
|||||||
@@ -123,13 +123,13 @@ export async function sendPushNotification(
|
|||||||
url: string,
|
url: string,
|
||||||
title: string,
|
title: string,
|
||||||
message: string
|
message: string
|
||||||
): Promise<{ success: boolean; error?: string }> {
|
): Promise<{ success: boolean; error?: string; providerMessageId?: string }> {
|
||||||
try {
|
try {
|
||||||
const result = await sendShoutrrrNotification(url, title, message);
|
const result = await sendShoutrrrNotification(url, title, message);
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
return { success: false, error: result.error };
|
return { success: false, error: result.error };
|
||||||
}
|
}
|
||||||
return { success: true };
|
return { success: true, providerMessageId: result.providerMessageId };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
||||||
return { success: false, error: errorMessage };
|
return { success: false, error: errorMessage };
|
||||||
|
|||||||
Reference in New Issue
Block a user