Add configuration to enable/disable web push notifications

push-fixes
Egor Kislitsyn 6 years ago
parent ebe2a95140
commit bbae2e10f3

@ -23,6 +23,7 @@ const defaultState = {
likes: true, likes: true,
repeats: true repeats: true
}, },
webPushNotifications: true,
muteWords: [], muteWords: [],
highlight: {}, highlight: {},
interfaceLanguage: browserLocale, interfaceLanguage: browserLocale,

@ -1,4 +1,3 @@
function urlBase64ToUint8Array (base64String) { function urlBase64ToUint8Array (base64String) {
const padding = '='.repeat((4 - base64String.length % 4) % 4) const padding = '='.repeat((4 - base64String.length % 4) % 4)
const base64 = (base64String + padding) const base64 = (base64String + padding)
@ -46,6 +45,10 @@ function askPermission () {
} }
function subscribe (registration, store) { function subscribe (registration, store) {
if (!store.rootState.config.webPushNotifications) {
return Promise.reject(new Error('Web Push is disabled in config'))
}
if (!store.rootState.instance.vapidPublicKey) { if (!store.rootState.instance.vapidPublicKey) {
return Promise.reject(new Error('VAPID publick key is not found')) return Promise.reject(new Error('VAPID publick key is not found'))
} }

Loading…
Cancel
Save