blob: 194cc0a8c7e40c20a75700692cd883142324e58b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
# frozen_string_literal: true
class REST::WebPushSubscriptionSerializer < ActiveModel::Serializer
attributes :id, :endpoint, :alerts, :server_key
def alerts
(object.data&.dig('alerts') || {}).each_with_object({}) { |(k, v), h| h[k] = ActiveModel::Type::Boolean.new.cast(v) }
end
def server_key
Rails.configuration.x.vapid_public_key
end
end
|