about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorSorin Davidoi <sorin.davidoi@gmail.com>2017-07-19 22:37:52 +0200
committerEugen Rochko <eugen@zeonfederated.com>2017-07-19 22:37:52 +0200
commitdcb94971484c46e470b89032f174267ace86be5c (patch)
tree31e7c7cf56e540edc6963e8147a5a291be947324 /app/models
parent4f2513337f77a9f05883b82e5b6a6e3a0dc10b14 (diff)
fix(push_subscription): Guard against malformed favourite notification (#4271)
Diffstat (limited to 'app/models')
-rw-r--r--app/models/web/push_subscription.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/app/models/web/push_subscription.rb b/app/models/web/push_subscription.rb
index dffdbbd05..86df9b591 100644
--- a/app/models/web/push_subscription.rb
+++ b/app/models/web/push_subscription.rb
@@ -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(