- action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
-
- plug(OAuthScopesPlug, %{scopes: ["read"]} when action == :index)
-
- plug(Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug)
-
- @doc "GET /api/v1/suggestions"
- def index(%{assigns: %{user: user}} = conn, _) do
- if Config.get([:suggestions, :enabled], false) do
- with {:ok, data} <- fetch_suggestions(user) do
- limit = Config.get([:suggestions, :limit], 23)
-
- data =
- data
- |> Enum.slice(0, limit)
- |> Enum.map(fn x ->
- x
- |> Map.put("id", fetch_suggestion_id(x))
- |> Map.put("avatar", MediaProxy.url(x["avatar"]))
- |> Map.put("avatar_static", MediaProxy.url(x["avatar_static"]))
- end)
-
- json(conn, data)
- end
- else
- json(conn, [])
- end
+ def open_api_operation(action) do
+ operation = String.to_existing_atom("#{action}_operation")
+ apply(__MODULE__, operation, [])