web_push_subscription_serializer.rb 277 Bytes
Newer Older
Rob Colbert's avatar
Rob Colbert committed
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') || {}
  end

  def server_key
    Rails.configuration.x.vapid_public_key
  end
end