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