Add test push notification flow

This commit is contained in:
zv
2026-06-11 19:36:23 +02:00
parent 054d75b1f4
commit b945fd4893
8 changed files with 88 additions and 3 deletions

View File

@@ -35,6 +35,15 @@ export async function deletePushSubscription(endpoint: string) {
if (!response.ok) throw new Error("Unable to delete push subscription.");
}
export async function sendTestPushNotification(endpoint: string) {
const response = await fetch("/api/notifications/test", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ endpoint }),
});
if (!response.ok) throw new Error("Unable to send test notification.");
}
export function decodeBase64UrlKey(value: string) {
const padding = "=".repeat((4 - (value.length % 4)) % 4);
const base64 = `${value}${padding}`.replace(/-/g, "+").replace(/_/g, "/");