question_validator: Allow content to be an empty-string (blank)
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Tue, 4 Aug 2020 12:23:35 +0000 (14:23 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Tue, 4 Aug 2020 12:29:16 +0000 (14:29 +0200)
lib/pleroma/web/activity_pub/object_validators/question_validator.ex
test/web/activity_pub/transmogrifier/question_handling_test.exs

index 466b3e6c2e3ee839222a33c4717d337d9649076d..d248c6aec2fb54c4a4c856b2ea2b97c5dddc67a4 100644 (file)
@@ -111,7 +111,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.QuestionValidator do
   def validate_data(data_cng) do
     data_cng
     |> validate_inclusion(:type, ["Question"])
-    |> validate_required([:id, :actor, :attributedTo, :type, :content, :context])
+    |> validate_required([:id, :actor, :attributedTo, :type, :context])
     |> CommonValidations.validate_any_presence([:cc, :to])
     |> CommonValidations.validate_fields_match([:actor, :attributedTo])
     |> CommonValidations.validate_actor_is_active()
index 12516c4abc5394cf9224f57ec702cebc3331bd29..9fb965d7facda0efba6daf8658fc5fb9673d8451 100644 (file)
@@ -111,4 +111,13 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.QuestionHandlingTest do
 
     assert {:error, {:validate_object, {:error, _}}} = Transmogrifier.handle_incoming(data)
   end
+
+  test "accepts a Question with no content" do
+    data =
+      File.read!("test/fixtures/mastodon-question-activity.json")
+      |> Poison.decode!()
+      |> Kernel.put_in(["object", "content"], "")
+
+    assert {:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(data)
+  end
 end