summaryrefslogtreecommitdiff
path: root/lib/pleroma/web/mastodon_api/controllers/mastodon_api_controller.ex
blob: a1bcc91d978701105e1e03e9a1f9e7d9d013a55d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
  @moduledoc """
  Contains stubs for unimplemented Mastodon API endpoints.

  Note: instead of routing directly to this controller's action,
    it's preferable to define an action in relevant (non-generic) controller,
    set up OAuth rules for it and call this controller's function from it.
  """

  use Pleroma.Web, :controller

  require Logger

  plug(
    :skip_plug,
    [Pleroma.Web.Plugs.OAuthScopesPlug, Pleroma.Web.Plugs.EnsurePublicOrAuthenticatedPlug]
    when action in [:empty_array, :empty_object]
  )

  action_fallback(Pleroma.Web.MastodonAPI.FallbackController)

  def empty_array(conn, _) do
    Logger.debug("Unimplemented, returning an empty array (list)")
    json(conn, [])
  end

  def empty_object(conn, _) do
    Logger.debug("Unimplemented, returning an empty object (map)")
    json(conn, %{})
  end
end