mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-06-19 19:13:13 +02:00
blerp
This commit is contained in:
parent
2e1ddc9ae1
commit
92bf7ebc52
11 changed files with 237 additions and 37 deletions
web/src/app
|
@ -8,7 +8,7 @@ import {
|
|||
topicUrlJsonPollWithSince,
|
||||
userAccountUrl,
|
||||
userTokenUrl,
|
||||
userStatsUrl
|
||||
userStatsUrl, userSubscriptionUrl, userSubscriptionDeleteUrl
|
||||
} from "./utils";
|
||||
import userManager from "./UserManager";
|
||||
|
||||
|
@ -186,6 +186,35 @@ class Api {
|
|||
throw new Error(`Unexpected server response ${response.status}`);
|
||||
}
|
||||
}
|
||||
|
||||
async userSubscriptionAdd(baseUrl, token, payload) {
|
||||
const url = userSubscriptionUrl(baseUrl);
|
||||
const body = JSON.stringify(payload);
|
||||
console.log(`[Api] Adding user subscription ${url}: ${body}`);
|
||||
const response = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: maybeWithBearerAuth({}, token),
|
||||
body: body
|
||||
});
|
||||
if (response.status !== 200) {
|
||||
throw new Error(`Unexpected server response ${response.status}`);
|
||||
}
|
||||
const subscription = await response.json();
|
||||
console.log(`[Api] Subscription`, subscription);
|
||||
return subscription;
|
||||
}
|
||||
|
||||
async userSubscriptionDelete(baseUrl, token, remoteId) {
|
||||
const url = userSubscriptionDeleteUrl(baseUrl, remoteId);
|
||||
console.log(`[Api] Removing user subscription ${url}`);
|
||||
const response = await fetch(url, {
|
||||
method: "DELETE",
|
||||
headers: maybeWithBearerAuth({}, token)
|
||||
});
|
||||
if (response.status !== 200) {
|
||||
throw new Error(`Unexpected server response ${response.status}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const api = new Api();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue