This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2018-05-11 02:49:12 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class REST::WebPushSubscriptionSerializer < ActiveModel::Serializer
|
2023-01-23 04:05:30 -08:00
|
|
|
attributes :id, :endpoint, :alerts, :server_key, :policy
|
2018-05-11 02:49:12 -07:00
|
|
|
|
|
|
|
def alerts
|
2019-07-21 09:10:07 -07:00
|
|
|
(object.data&.dig('alerts') || {}).each_with_object({}) { |(k, v), h| h[k] = ActiveModel::Type::Boolean.new.cast(v) }
|
2018-05-11 02:49:12 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def server_key
|
|
|
|
Rails.configuration.x.vapid_public_key
|
|
|
|
end
|
2023-01-23 04:05:30 -08:00
|
|
|
|
|
|
|
def policy
|
|
|
|
object.data&.dig('policy') || 'all'
|
|
|
|
end
|
2018-05-11 02:49:12 -07:00
|
|
|
end
|