Improved notifications
This commit is contained in:
parent
4ad52042ba
commit
2d139e6381
@ -166,10 +166,15 @@ func (user *User) SendNotification(pushNotification *PushNotification) {
|
||||
expired := []*PushSubscription{}
|
||||
|
||||
for _, sub := range subs.Items {
|
||||
if sub.Endpoint == "" {
|
||||
expired = append(expired, sub)
|
||||
continue
|
||||
}
|
||||
|
||||
response, err := sub.SendNotification(pushNotification)
|
||||
|
||||
// It is possible to receive a non-nil response with an error, so check the status.
|
||||
if response != nil && response.StatusCode == http.StatusGone {
|
||||
if response != nil && (response.StatusCode == http.StatusGone || response.StatusCode == http.StatusForbidden) {
|
||||
expired = append(expired, sub)
|
||||
}
|
||||
|
||||
|
@ -9,25 +9,25 @@ component SettingsNotifications(user *arn.User)
|
||||
Icon("bell")
|
||||
span Instant notifications
|
||||
|
||||
#enable-notifications.widget-section
|
||||
#notifications-enable.widget-section
|
||||
label Instant notifications:
|
||||
button.action(data-action="enableNotifications", data-trigger="click")
|
||||
Icon("toggle-off")
|
||||
span OFF
|
||||
|
||||
#disable-notifications.widget-section.hidden
|
||||
#notifications-disable.widget-section.hidden
|
||||
label Instant notifications:
|
||||
button.action(data-action="disableNotifications", data-trigger="click")
|
||||
Icon("toggle-on")
|
||||
span ON
|
||||
|
||||
#test-notification.widget-section
|
||||
#notifications-test.widget-section
|
||||
label Test:
|
||||
button.action(data-action="testNotification", data-trigger="click")
|
||||
Icon("paper-plane")
|
||||
span Send test notification
|
||||
|
||||
footer.footer
|
||||
footer#notifications-footer.footer
|
||||
p(title="This setting is not account bound, instead it is bound to your browser.") You can customize this setting on every device you own.
|
||||
|
||||
//- .widget.mountable(data-api="/api/settings/" + user.ID)
|
||||
|
@ -306,14 +306,16 @@ export default class AnimeNotifier {
|
||||
return
|
||||
}
|
||||
|
||||
const enableButton = document.getElementById("enable-notifications") as HTMLButtonElement
|
||||
const disableButton = document.getElementById("disable-notifications") as HTMLButtonElement
|
||||
const testButton = document.getElementById("test-notification") as HTMLButtonElement
|
||||
const enableButton = document.getElementById("notifications-enable") as HTMLButtonElement
|
||||
const disableButton = document.getElementById("notifications-disable") as HTMLButtonElement
|
||||
const testButton = document.getElementById("notifications-test") as HTMLButtonElement
|
||||
const footer = document.getElementById("notifications-footer") as HTMLElement
|
||||
|
||||
if(!this.pushManager.pushSupported) {
|
||||
enableButton.classList.add("hidden")
|
||||
disableButton.classList.add("hidden")
|
||||
testButton.innerHTML = "Your browser doesn't support push notifications!"
|
||||
testButton.classList.add("hidden")
|
||||
footer.innerHTML = "Your browser doesn't support push notifications!"
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ export default class PushManager {
|
||||
}
|
||||
}
|
||||
|
||||
return fetch("/api/pushsubscriptions/" + userId + "/add", {
|
||||
return fetch(`/api/pushsubscriptions/${userId}/add`, {
|
||||
method: "POST",
|
||||
credentials: "same-origin",
|
||||
body: JSON.stringify(pushSubscription)
|
||||
|
Loading…
Reference in New Issue
Block a user