status_controller.ex: Posting media status without content defined
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Fri, 27 Sep 2019 23:21:28 +0000 (01:21 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Fri, 27 Sep 2019 23:53:41 +0000 (01:53 +0200)
lib/pleroma/web/mastodon_api/controllers/status_controller.ex
test/web/mastodon_api/controllers/status_controller_test.exs

index f7da10289f5c41df835d3bc37cbc14ed8c787590..ae3d515755148e24c7f301165a6d479dc3c7f742 100644 (file)
@@ -103,6 +103,10 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
     end
   end
 
+  def create(%{assigns: %{user: _user}} = conn, %{"media_ids" => _} = params) do
+    create(conn, Map.put(params, "status", ""))
+  end
+
   @doc "GET /api/v1/statuses/:id"
   def show(%{assigns: %{user: user}} = conn, %{"id" => id}) do
     with %Activity{} = activity <- Activity.get_by_id_with_object(id),
index c0121ac63b8208603602b3db48ba209408152a77..b194feae607ba1fb37a60838869d11eeb7224476 100644 (file)
@@ -99,7 +99,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
                NaiveDateTime.to_iso8601(expiration.scheduled_at)
     end
 
-    test "posting an empty status with an attachment", %{conn: conn} do
+    test "posting an undefined status with an attachment", %{conn: conn} do
       user = insert(:user)
 
       file = %Plug.Upload{
@@ -114,8 +114,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
         conn
         |> assign(:user, user)
         |> post("/api/v1/statuses", %{
-          "media_ids" => [to_string(upload.id)],
-          "status" => ""
+          "media_ids" => [to_string(upload.id)]
         })
 
       assert json_response(conn, 200)