logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

push_subscription_view.ex (594B)


      1 # Pleroma: A lightweight social networking server
      2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
      3 # SPDX-License-Identifier: AGPL-3.0-only
      4 
      5 defmodule Pleroma.Web.MastodonAPI.PushSubscriptionView do
      6   use Pleroma.Web, :view
      7   alias Pleroma.Web.Push
      8 
      9   def render("push_subscription.json", %{subscription: subscription}) do
     10     %{
     11       id: to_string(subscription.id),
     12       endpoint: subscription.endpoint,
     13       alerts: Map.get(subscription.data, "alerts"),
     14       server_key: server_key()
     15     }
     16   end
     17 
     18   defp server_key, do: Keyword.get(Push.vapid_config(), :public_key)
     19 end