1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.MastodonAPI.MarkerController do
6 use Pleroma.Web, :controller
7 alias Pleroma.Plugs.OAuthScopesPlug
9 plug(Pleroma.Web.ApiSpec.CastAndValidate)
13 %{scopes: ["read:statuses"]}
17 plug(OAuthScopesPlug, %{scopes: ["write:statuses"]} when action == :upsert)
19 action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
21 defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.MarkerOperation
24 def index(%{assigns: %{user: user}} = conn, params) do
25 markers = Pleroma.Marker.get_markers(user, params[:timeline])
26 render(conn, "markers.json", %{markers: markers})
29 # POST /api/v1/markers
30 def upsert(%{assigns: %{user: user}, body_params: params} = conn, _) do
31 params = Map.new(params, fn {key, value} -> {to_string(key), value} end)
33 with {:ok, result} <- Pleroma.Marker.upsert(user, params),
34 markers <- Map.values(result) do
35 render(conn, "markers.json", %{markers: markers})