mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-19 00:16:05 +01:00
Send notification on 3 push failures
This commit is contained in:
parent
fccf35fdab
commit
e0195654b5
4 changed files with 26 additions and 0 deletions
4
app/models/notification/push_subscription_error.rb
Normal file
4
app/models/notification/push_subscription_error.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Notification::PushSubscriptionError < Notification
|
||||
end
|
10
app/views/notifications/type/_webpushsubscription.html.haml
Normal file
10
app/views/notifications/type/_webpushsubscription.html.haml
Normal file
|
@ -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.increment :failures
|
||||
subscription.save
|
||||
|
||||
if subscription.failures > 3
|
||||
Notification::PushSubscriptionError.create(
|
||||
target: subscription,
|
||||
recipient: subscription.user,
|
||||
new: true
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -354,6 +354,10 @@ en:
|
|||
link_text: "your comment"
|
||||
follow:
|
||||
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:
|
||||
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."
|
||||
|
|
Loading…
Reference in a new issue