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("index.json", %{apps: apps}) do
19 render_many(apps, Pleroma.Web.MastodonAPI.AppView, "show.json")
22 def render("show.json", %{admin: true, app: %App{} = app} = assigns) do
24 |> render(Map.delete(assigns, :admin))
25 |> Map.put(:trusted, app.trusted)
26 |> Map.put(:id, app.id)
29 def render("show.json", %{app: %App{} = app}) do
31 id: app.id |> to_string,
32 name: app.client_name,
33 client_id: app.client_id,
34 client_secret: app.client_secret,
35 redirect_uri: app.redirect_uris,
41 def render("compact_non_secret.json", %{app: %App{website: website, client_name: name}}) do
49 defp with_vapid_key(data) do
50 vapid_key = Application.get_env(:web_push_encryption, :vapid_details, [])[:public_key]
52 Pleroma.Maps.put_if_present(data, "vapid_key", vapid_key)