|
|
|
@ -26,8 +26,6 @@ class Web::PushSubscription < ApplicationRecord |
|
|
|
|
before_create :send_welcome_notification |
|
|
|
|
|
|
|
|
|
def push(notification) |
|
|
|
|
return unless pushable? notification |
|
|
|
|
|
|
|
|
|
name = display_name notification.from_account |
|
|
|
|
title = title_str(name, notification) |
|
|
|
|
body = body_str notification |
|
|
|
@ -69,6 +67,10 @@ class Web::PushSubscription < ApplicationRecord |
|
|
|
|
) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def pushable?(notification) |
|
|
|
|
data && data.key?('alerts') && data['alerts'][notification.type.to_s] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def as_payload |
|
|
|
|
payload = { |
|
|
|
|
id: id, |
|
|
|
@ -148,10 +150,6 @@ class Web::PushSubscription < ApplicationRecord |
|
|
|
|
rtl?(body) ? 'rtl' : 'ltr' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def pushable?(notification) |
|
|
|
|
data && data.key?('alerts') && data['alerts'][notification.type.to_s] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def send_welcome_notification |
|
|
|
|
Webpush.payload_send( |
|
|
|
|
message: JSON.generate( |
|
|
|
|