about summary refs log tree commit diff
diff options
context:
space:
mode:
authorunarist <m.unarist@gmail.com>2017-09-02 23:50:42 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-09-02 16:50:42 +0200
commitbfa7f9ebf22581a387606716fe3f86e85e1c9db5 (patch)
treeaecbbc735b67607924499ae717d1a753e7f2f79d
parent8cc1ed3c556830092601425881384f8667dec437 (diff)
Fix WebPush (regression from #4524) (#4778)
* Fix NoMethodError in Web::PushSubscription

```
undefined method `site_contact_email' for #<Class:0x00005976d13c40>

/usr/local/bundle/gems/activerecord-5.1.3/lib/active_record/dynamic_matchers.rb:22:in `method_missing'
/usr/local/bundle/gems/attr_encrypted-3.0.3/lib/attr_encrypted.rb:295:in `method_missing'
/usr/local/bundle/gems/attr_encrypted-3.0.3/lib/attr_encrypted/adapters/active_record.rb:129:in `method_missing_with_attr_encrypted'
/mastodon/app/models/web/push_subscription.rb:53:in `push_payload'
```

* Specify serializer in Web::NotificationSerializer
-rw-r--r--app/models/web/push_subscription.rb2
-rw-r--r--app/serializers/web/notification_serializer.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/app/models/web/push_subscription.rb b/app/models/web/push_subscription.rb
index 79f782114..cb15dfa37 100644
--- a/app/models/web/push_subscription.rb
+++ b/app/models/web/push_subscription.rb
@@ -50,7 +50,7 @@ class Web::PushSubscription < ApplicationRecord
       auth: key_auth,
       ttl: ttl,
       vapid: {
-        subject: "mailto:#{Setting.site_contact_email}",
+        subject: "mailto:#{::Setting.site_contact_email}",
         private_key: Rails.configuration.x.vapid_private_key,
         public_key: Rails.configuration.x.vapid_public_key,
       }
diff --git a/app/serializers/web/notification_serializer.rb b/app/serializers/web/notification_serializer.rb
index 21a09f01e..e5524fe7a 100644
--- a/app/serializers/web/notification_serializer.rb
+++ b/app/serializers/web/notification_serializer.rb
@@ -121,7 +121,7 @@ class Web::NotificationSerializer < ActiveModel::Serializer
   attributes :title, :image, :badge, :tag,
              :timestamp, :icon
 
-  has_one :data
+  has_one :data, serializer: DataSerializer
 
   def title
     case object.type