2018-12-23 13:04:54 -07:00
|
|
|
# Pleroma: A lightweight social networking server
|
2021-01-12 23:49:20 -07:00
|
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
2018-12-23 13:04:54 -07:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-04-15 12:59:25 -06:00
|
|
|
defmodule Pleroma.Web.MastodonAPI.SubscriptionView do
|
2018-09-18 03:56:46 -06:00
|
|
|
use Pleroma.Web, :view
|
2019-03-06 06:20:12 -07:00
|
|
|
alias Pleroma.Web.Push
|
2018-09-18 03:56:46 -06:00
|
|
|
|
2020-04-15 12:59:25 -06:00
|
|
|
def render("show.json", %{subscription: subscription}) do
|
2018-09-18 03:56:46 -06:00
|
|
|
%{
|
|
|
|
id: to_string(subscription.id),
|
|
|
|
endpoint: subscription.endpoint,
|
2018-12-07 01:55:28 -07:00
|
|
|
alerts: Map.get(subscription.data, "alerts"),
|
|
|
|
server_key: server_key()
|
2018-09-18 03:56:46 -06:00
|
|
|
}
|
|
|
|
end
|
2018-12-07 01:55:28 -07:00
|
|
|
|
2019-03-06 06:20:12 -07:00
|
|
|
defp server_key, do: Keyword.get(Push.vapid_config(), :public_key)
|
2018-09-18 03:56:46 -06:00
|
|
|
end
|