Improved notifications

This commit is contained in:
2019-11-20 16:47:00 +09:00
parent 4ad52042ba
commit 2d139e6381
4 changed files with 17 additions and 10 deletions

View File

@ -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)
}