Merge branch 'bugfix/mrf-reject-logging' into 'develop'
[akkoma] / lib / pleroma / web / mastodon_api / controllers / status_controller.ex
index 468b44b6758ea43f89d67fb7603d6c19a1dabb2b..9bb2ef117b414f15b40ca78fd3e729d5adf25029 100644 (file)
@@ -172,6 +172,11 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
         with_direct_conversation_id: true
       )
     else
+      {:error, {:reject, message}} ->
+        conn
+        |> put_status(:unprocessable_entity)
+        |> json(%{error: message})
+
       {:error, message} ->
         conn
         |> put_status(:unprocessable_entity)
@@ -200,11 +205,16 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
 
   @doc "DELETE /api/v1/statuses/:id"
   def delete(%{assigns: %{user: user}} = conn, %{id: id}) do
-    with {:ok, %Activity{}} <- CommonAPI.delete(id, user) do
-      json(conn, %{})
+    with %Activity{} = activity <- Activity.get_by_id_with_object(id),
+         {:ok, %Activity{}} <- CommonAPI.delete(id, user) do
+      try_render(conn, "show.json",
+        activity: activity,
+        for: user,
+        with_direct_conversation_id: true,
+        with_source: true
+      )
     else
-      {:error, :not_found} = e -> e
-      _e -> render_error(conn, :forbidden, "Can't delete this post")
+      _e -> {:error, :not_found}
     end
   end