Merge branch 'remake-remodel' into develop
[akkoma] / lib / pleroma / web / mastodon_api / controllers / status_controller.ex
index b0048102fd2bccf92e95b7b3cc5906ff40870b79..83cd2c768f4db6c2894f491c8e816fd0efc20b03 100644 (file)
@@ -175,6 +175,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
         for: user,
         with_direct_conversation_id: true
       )
+    else
+      _ -> {:error, :not_found}
     end
   end
 
@@ -183,6 +185,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
     with {:ok, %Activity{}} <- CommonAPI.delete(id, user) do
       json(conn, %{})
     else
+      {:error, :not_found} = e -> e
       _e -> render_error(conn, :forbidden, "Can't delete this post")
     end
   end
@@ -204,9 +207,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
   end
 
   @doc "POST /api/v1/statuses/:id/favourite"
-  def favourite(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) do
-    with {:ok, _fav, %{data: %{"id" => id}}} <- CommonAPI.favorite(ap_id_or_id, user),
-         %Activity{} = activity <- Activity.get_create_by_object_ap_id(id) do
+  def favourite(%{assigns: %{user: user}} = conn, %{"id" => activity_id}) do
+    with {:ok, _fav} <- CommonAPI.favorite(user, activity_id),
+         %Activity{} = activity <- Activity.get_by_id(activity_id) do
       try_render(conn, "show.json", activity: activity, for: user, as: :activity)
     end
   end