aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/mastodon_api/controllers
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2019-10-23 17:22:42 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2019-10-23 17:22:42 +0300
commit8cc809e44e3a899f93061c4c5f68d9736d79d79e (patch)
tree8193991e2a2b705a60d847a626d22abaf756d7f1 /lib/pleroma/web/mastodon_api/controllers
parent11cd9944258bfc2123b821b21321e12097d0f19b (diff)
parent54077677eaad44ea355c7f0db7ea5e94183d5a30 (diff)
downloadpleroma-8cc809e44e3a899f93061c4c5f68d9736d79d79e.tar.gz
Merge remote-tracking branch 'remotes/upstream/develop' into 1304-user-info-deprecation
# Conflicts: # lib/pleroma/notification.ex
Diffstat (limited to 'lib/pleroma/web/mastodon_api/controllers')
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/marker_controller.ex32
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