diff options
author | Maksim Pechnikov <parallel588@gmail.com> | 2019-10-17 15:26:59 +0300 |
---|---|---|
committer | Maksim Pechnikov <parallel588@gmail.com> | 2019-10-17 15:26:59 +0300 |
commit | 66b5d0ff558bffeddf6475af72b73bf2870512f6 (patch) | |
tree | b46326a6ab9c90eccb6f396d310695802141ab95 /lib/pleroma/web/mastodon_api/controllers | |
parent | e3b4a3e96b2ffbc6d920155cd41687414045d4d6 (diff) | |
download | pleroma-66b5d0ff558bffeddf6475af72b73bf2870512f6.tar.gz |
add Markers /api/v1/markers
Diffstat (limited to 'lib/pleroma/web/mastodon_api/controllers')
-rw-r--r-- | lib/pleroma/web/mastodon_api/controllers/marker_controller.ex | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/pleroma/web/mastodon_api/controllers/marker_controller.ex b/lib/pleroma/web/mastodon_api/controllers/marker_controller.ex new file mode 100644 index 000000000..ce025624d --- /dev/null +++ b/lib/pleroma/web/mastodon_api/controllers/marker_controller.ex @@ -0,0 +1,32 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Web.MastodonAPI.MarkerController do + use Pleroma.Web, :controller + alias Pleroma.Plugs.OAuthScopesPlug + + plug( + OAuthScopesPlug, + %{scopes: ["read:statuses"]} + when action == :index + ) + + plug(OAuthScopesPlug, %{scopes: ["write:statuses"]} when action == :upsert) + plug(Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug) + action_fallback(Pleroma.Web.MastodonAPI.FallbackController) + + # GET /api/v1/markers + def index(%{assigns: %{user: user}} = conn, params) do + markers = Pleroma.Marker.get_markers(user, params["timeline"]) + render(conn, "markers.json", %{markers: markers}) + end + + # POST /api/v1/markers + def upsert(%{assigns: %{user: user}} = conn, params) do + with {:ok, result} <- Pleroma.Marker.upsert(user, params), + markers <- Map.values(result) do + render(conn, "markers.json", %{markers: markers}) + end + end +end |