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