summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>2023-12-29 05:23:01 +0100
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>2023-12-29 05:32:47 +0100
commit39dc6c65ef7a95412a985a3edce019914af12df8 (patch)
tree27262f0020b28d00621a8f7bc9648a8778bc1899 /test
parent47e00524f7c443d5313c1b05f05d61f50c3a1f7c (diff)
ChatMessage: Tolerate attachment field set to an empty array
Closes: https://git.pleroma.social/pleroma/pleroma/-/issues/3224
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs b/test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs
index 812944452..301fed60d 100644
--- a/test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs
@@ -147,6 +147,21 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ChatValidationTest do
assert object["attachment"]
end
+ test "validates for a basic object with content but attachment set to empty array", %{
+ user: user,
+ recipient: recipient
+ } do
+ {:ok, valid_chat_message, _} = Builder.chat_message(user, recipient.ap_id, "Hello!")
+
+ valid_chat_message =
+ valid_chat_message
+ |> Map.put("attachment", [])
+
+ assert {:ok, object, _meta} = ObjectValidator.validate(valid_chat_message, [])
+
+ assert object == Map.drop(valid_chat_message, ["attachment"])
+ end
+
test "does not validate if the message has no content", %{
valid_chat_message: valid_chat_message
} do