summaryrefslogtreecommitdiff
path: root/lib/pleroma/web/pleroma_api/controllers/app_controller.ex
blob: d857f424f98ec19929174a720c756d003b0dfa20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Web.PleromaAPI.AppController do
  use Pleroma.Web, :controller

  alias Pleroma.Web.OAuth.App
  alias Pleroma.Web.Plugs.OAuthScopesPlug

  plug(OAuthScopesPlug, %{scopes: ["follow", "read"]} when action in [:index])

  plug(Pleroma.Web.ApiSpec.CastAndValidate)

  defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.PleromaAppOperation

  @doc "GET /api/v1/pleroma/apps"
  def index(%{assigns: %{user: user}} = conn, _params) do
    with apps <- App.get_user_apps(user) do
      render(conn, "index.json", %{apps: apps})
    end
  end
end