X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Fmastodon_api%2Fcontrollers%2Fconversation_controller.ex;h=f2a0949e853c62475af264f8300a1702a2d5ab20;hb=92a8ff59aa7f81e2463775669ada54f618d8c684;hp=69f0e384600ae80b9698638da7c4767d141cb6b2;hpb=6d4b80822b15f5958518f4c6006862fb1f92354a;p=akkoma
diff --git a/lib/pleroma/web/mastodon_api/controllers/conversation_controller.ex b/lib/pleroma/web/mastodon_api/controllers/conversation_controller.ex
index 69f0e3846..f2a0949e8 100644
--- a/lib/pleroma/web/mastodon_api/controllers/conversation_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/conversation_controller.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.ConversationController do
@@ -8,8 +8,8 @@ defmodule Pleroma.Web.MastodonAPI.ConversationController do
import Pleroma.Web.ControllerHelper, only: [add_link_headers: 2]
alias Pleroma.Conversation.Participation
- alias Pleroma.Plugs.OAuthScopesPlug
alias Pleroma.Repo
+ alias Pleroma.Web.Plugs.OAuthScopesPlug
action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
@@ -21,7 +21,6 @@ defmodule Pleroma.Web.MastodonAPI.ConversationController do
@doc "GET /api/v1/conversations"
def index(%{assigns: %{user: user}} = conn, params) do
- params = stringify_pagination_params(params)
participations = Participation.for_user_with_last_activity_id(user, params)
conn
@@ -38,19 +37,12 @@ defmodule Pleroma.Web.MastodonAPI.ConversationController do
end
end
- defp stringify_pagination_params(params) do
- atom_keys =
- Pleroma.Pagination.page_keys()
- |> Enum.map(&String.to_atom(&1))
-
- str_keys =
- params
- |> Map.take(atom_keys)
- |> Enum.map(fn {key, value} -> {to_string(key), value} end)
- |> Enum.into(%{})
-
- params
- |> Map.delete(atom_keys)
- |> Map.merge(str_keys)
+ @doc "DELETE /api/v1/conversations/:id"
+ def delete(%{assigns: %{user: user}} = conn, %{id: participation_id}) do
+ with %Participation{} = participation <-
+ Repo.get_by(Participation, id: participation_id, user_id: user.id),
+ {:ok, _} <- Participation.delete(participation) do
+ json(conn, %{})
+ end
end
end