a1bcc91d978701105e1e03e9a1f9e7d9d013a55d
[akkoma] / lib / pleroma / web / mastodon_api / controllers / mastodon_api_controller.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
6 @moduledoc """
7 Contains stubs for unimplemented Mastodon API endpoints.
8
9 Note: instead of routing directly to this controller's action,
10 it's preferable to define an action in relevant (non-generic) controller,
11 set up OAuth rules for it and call this controller's function from it.
12 """
13
14 use Pleroma.Web, :controller
15
16 require Logger
17
18 plug(
19 :skip_plug,
20 [Pleroma.Web.Plugs.OAuthScopesPlug, Pleroma.Web.Plugs.EnsurePublicOrAuthenticatedPlug]
21 when action in [:empty_array, :empty_object]
22 )
23
24 action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
25
26 def empty_array(conn, _) do
27 Logger.debug("Unimplemented, returning an empty array (list)")
28 json(conn, [])
29 end
30
31 def empty_object(conn, _) do
32 Logger.debug("Unimplemented, returning an empty object (map)")
33 json(conn, %{})
34 end
35 end