1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.MastodonAPI.AppView do
8 alias Pleroma.Web.OAuth.App
10 def render("index.json", %{apps: apps, count: count, page_size: page_size, admin: true}) do
12 apps: render_many(apps, Pleroma.Web.MastodonAPI.AppView, "show.json", %{admin: true}),
18 def render("show.json", %{admin: true, app: %App{} = app} = assigns) do
20 |> render(Map.delete(assigns, :admin))
21 |> Map.put(:trusted, app.trusted)
22 |> Map.put(:id, app.id)
25 def render("show.json", %{app: %App{} = app}) do
27 id: app.id |> to_string,
28 name: app.client_name,
29 client_id: app.client_id,
30 client_secret: app.client_secret,
31 redirect_uri: app.redirect_uris,
37 def render("compact_non_secret.json", %{app: %App{website: website, client_name: name}}) do
45 defp with_vapid_key(data) do
46 vapid_key = Application.get_env(:web_push_encryption, :vapid_details, [])[:public_key]
48 Pleroma.Maps.put_if_present(data, "vapid_key", vapid_key)