mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-07-09 04:24:43 +02:00
Make DELETE endpoint, add different UI description
This commit is contained in:
parent
eb220544a3
commit
58992fc795
5 changed files with 47 additions and 16 deletions
web/src/app
|
@ -115,14 +115,13 @@ class Api {
|
|||
throw new Error(`Unexpected server response ${response.status}`);
|
||||
}
|
||||
|
||||
async updateWebPushSubscriptions(topics, pushSubscription) {
|
||||
async updateWebPush(pushSubscription, topics) {
|
||||
const user = await userManager.get(config.base_url);
|
||||
const url = accountWebPushUrl(config.base_url);
|
||||
console.log(`[Api] Sending Web Push Subscriptions`, { url, topics, endpoint: pushSubscription.endpoint });
|
||||
console.log(`[Api] Sending Web Push Subscriptions`, { pushSubscription });
|
||||
console.log(`[Api] Updating Web Push subscription`, { url, topics, endpoint: pushSubscription.endpoint });
|
||||
const serializedSubscription = JSON.parse(JSON.stringify(pushSubscription)); // Ugh ... https://stackoverflow.com/a/40525434/1440785
|
||||
await fetchOrThrow(url, {
|
||||
method: "PUT",
|
||||
method: "POST",
|
||||
headers: maybeWithAuth({}, user),
|
||||
body: JSON.stringify({
|
||||
endpoint: serializedSubscription.endpoint,
|
||||
|
@ -132,6 +131,20 @@ class Api {
|
|||
}),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async deleteWebPush(pushSubscription) {
|
||||
const user = await userManager.get(config.base_url);
|
||||
const url = accountWebPushUrl(config.base_url);
|
||||
console.log(`[Api] Deleting Web Push subscription`, { url, endpoint: pushSubscription.endpoint });
|
||||
await fetchOrThrow(url, {
|
||||
method: "DELETE",
|
||||
headers: maybeWithAuth({}, user),
|
||||
body: JSON.stringify({
|
||||
endpoint: pushSubscription.endpoint
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const api = new Api();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue