feat: webhook support

This commit is contained in:
neoarz
2026-04-22 22:02:36 -04:00
parent 2d003eaaee
commit 734a6cdde3
5 changed files with 407 additions and 35 deletions

28
native.ts Normal file
View File

@@ -0,0 +1,28 @@
import { IpcMainInvokeEvent } from "electron";
import type { NativeWebhookResponse } from "./types";
export async function sendWebhook(_: IpcMainInvokeEvent, webhookUrl: string, payload: string): Promise<NativeWebhookResponse> {
try {
const url = new URL(webhookUrl);
url.searchParams.set("wait", "true");
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: payload
});
return {
status: response.status,
data: await response.text()
};
} catch (error) {
return {
status: -1,
data: String(error)
};
}
}