Send notification on 3 push failures
This commit is contained in:
parent
fccf35fdab
commit
e0195654b5
|
@ -0,0 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Notification::PushSubscriptionError < Notification
|
||||||
|
end
|
|
@ -0,0 +1,10 @@
|
||||||
|
.media.notification
|
||||||
|
.notification__icon
|
||||||
|
%span.fa-stack
|
||||||
|
%i.fa.fa-2x.fa-fw.fa-bell
|
||||||
|
%i.fa.fa-stack-1x.fa-fw.fa-exclamation-triangle.text-danger.pl-2
|
||||||
|
.media-body
|
||||||
|
%h6.media-heading.notification__user
|
||||||
|
= t(".heading")
|
||||||
|
.notification__text
|
||||||
|
= t(".text_html", settings_push: link_to(t(".settings_push"), settings_push_notifications_path))
|
|
@ -63,6 +63,14 @@ Rpush.reflect do |on|
|
||||||
subscription = WebPushSubscription::where("subscription ->> 'endpoint' = ?", notification.registration_ids.first[:endpoint])
|
subscription = WebPushSubscription::where("subscription ->> 'endpoint' = ?", notification.registration_ids.first[:endpoint])
|
||||||
subscription.increment :failures
|
subscription.increment :failures
|
||||||
subscription.save
|
subscription.save
|
||||||
|
|
||||||
|
if subscription.failures > 3
|
||||||
|
Notification::PushSubscriptionError.create(
|
||||||
|
target: subscription,
|
||||||
|
recipient: subscription.user,
|
||||||
|
new: true
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -354,6 +354,10 @@ en:
|
||||||
link_text: "your comment"
|
link_text: "your comment"
|
||||||
follow:
|
follow:
|
||||||
heading_html: "followed you %{time} ago"
|
heading_html: "followed you %{time} ago"
|
||||||
|
webpushsubscription:
|
||||||
|
heading: "Push notifications are failing to send to one of your devices."
|
||||||
|
text_html: "Please check the %{settings_push} if you still want to be notified."
|
||||||
|
settings_push: "push notification settings"
|
||||||
expiredtwitterserviceconnection:
|
expiredtwitterserviceconnection:
|
||||||
heading: "Twitter connection expired"
|
heading: "Twitter connection expired"
|
||||||
text_html: "If you would like to continue automatically sharing your answers to Twitter, head to %{settings_sharing} and re-connect your account."
|
text_html: "If you would like to continue automatically sharing your answers to Twitter, head to %{settings_sharing} and re-connect your account."
|
||||||
|
|
Loading…
Reference in New Issue