A platform for community discussion. Free, open, simple.
FIX: Delete push subscription on MismatchSenderId error
Gerhard Schlager17f1a765708b
diff --git a/app/services/push_notification_pusher.rb b/app/services/push_notification_pusher.rbindex 3a633788652..39155a771a3 100644--- a/app/services/push_notification_pusher.rb+++ b/app/services/push_notification_pusher.rb@@ -88,15 +88,19 @@ class PushNotificationPusherrescue Webpush::ExpiredSubscriptionunsubscribe(user, subscription)rescue Webpush::ResponseError => e- Discourse.warn_exception(- e,- message: "Failed to send push notification",- env: {- user_id: user.id,- endpoint: subscription["endpoint"],- message: message.to_json- }- )+ if e.response.message == "MismatchSenderId"+ unsubscribe(user, subscription)+ else+ Discourse.warn_exception(+ e,+ message: "Failed to send push notification",+ env: {+ user_id: user.id,+ endpoint: subscription["endpoint"],+ message: message.to_json+ }+ )+ endendendend