Check for empty string in_reply_to ids.
authorlain <lain@soykaf.club>
Fri, 2 Nov 2018 16:33:51 +0000 (17:33 +0100)
committerlain <lain@soykaf.club>
Fri, 2 Nov 2018 16:33:51 +0000 (17:33 +0100)
lib/pleroma/web/common_api/utils.ex
test/web/mastodon_api/mastodon_api_controller_test.exs

index 2a5a2cc15fcfb53efe6f2d3f7a5e00060a1d21dd..b22c4cc033445a68e7be33f80e519eb411c00fbf 100644 (file)
@@ -19,6 +19,8 @@ defmodule Pleroma.Web.CommonAPI.Utils do
       end
   end
 
+  def get_replied_to_activity(""), do: nil
+
   def get_replied_to_activity(id) when not is_nil(id) do
     Repo.get(Activity, id)
   end
index 42a43f129f2e2d33bcd12db3b443f289ad589d82..938d556c762d4e9f2bc98026fc3f91ee820eb38f 100644 (file)
@@ -198,6 +198,21 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
     assert activity.data["object"]["inReplyToStatusId"] == replied_to.id
   end
 
+  test "posting a status with an invalid in_reply_to_id", %{conn: conn} do
+    user = insert(:user)
+
+    conn =
+      conn
+      |> assign(:user, user)
+      |> post("/api/v1/statuses", %{"status" => "xD", "in_reply_to_id" => ""})
+
+    assert %{"content" => "xD", "id" => id} = json_response(conn, 200)
+
+    activity = Repo.get(Activity, id)
+
+    assert activity
+  end
+
   test "verify_credentials", %{conn: conn} do
     user = insert(:user)