2018-05-11 19:49:12 +10:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class REST::WebPushSubscriptionSerializer < ActiveModel::Serializer
|
|
|
|
attributes :id, :endpoint, :alerts, :server_key
|
|
|
|
|
|
|
|
def alerts
|
2019-07-22 02:10:07 +10:00
|
|
|
(object.data&.dig('alerts') || {}).each_with_object({}) { |(k, v), h| h[k] = ActiveModel::Type::Boolean.new.cast(v) }
|
2018-05-11 19:49:12 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
def server_key
|
|
|
|
Rails.configuration.x.vapid_public_key
|
|
|
|
end
|
|
|
|
end
|