baa1e03bdb038a4b70fbf66eef1232b50052717c
[anni] / lib / pleroma / web / mastodon_api / views / subscription_view.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.MastodonAPI.SubscriptionView do
6   use Pleroma.Web, :view
7   alias Pleroma.Web.Push
8
9   def render("show.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