mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-06-18 10:33:11 +02:00
Move web-push-config endpoint to config.js
This commit is contained in:
parent
9e0687e142
commit
e8139ad655
7 changed files with 11 additions and 57 deletions
web/src/app
|
@ -53,7 +53,7 @@ class Notifier {
|
|||
}
|
||||
|
||||
async subscribeWebPush(baseUrl, topic) {
|
||||
if (!this.supported() || !this.pushSupported()) {
|
||||
if (!this.supported() || !this.pushSupported() || !config.enable_web_push) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -71,21 +71,12 @@ class Notifier {
|
|||
}
|
||||
|
||||
try {
|
||||
const webPushConfig = await api.getWebPushConfig(baseUrl);
|
||||
|
||||
if (!webPushConfig) {
|
||||
console.log("[Notifier.subscribeWebPush] Web push not configured on server");
|
||||
}
|
||||
|
||||
const browserSubscription = await registration.pushManager.subscribe({
|
||||
userVisibleOnly: true,
|
||||
applicationServerKey: urlB64ToUint8Array(webPushConfig.public_key),
|
||||
applicationServerKey: urlB64ToUint8Array(config.web_push_public_key),
|
||||
});
|
||||
|
||||
await api.subscribeWebPush(baseUrl, topic, browserSubscription);
|
||||
|
||||
console.log("[Notifier.subscribeWebPush] Successfully subscribed to web push");
|
||||
|
||||
return browserSubscription;
|
||||
} catch (e) {
|
||||
console.error("[Notifier.subscribeWebPush] Error subscribing to web push", e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue