diff options
author | lain <lain@soykaf.club> | 2020-05-13 15:31:28 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-05-13 15:31:28 +0200 |
commit | 0f0acc740d30c47d093f27875d4decf0693b2845 (patch) | |
tree | 0cdc813d983f535898c515d4a87a503bb7d3acd1 /test/web/activity_pub | |
parent | 06cad239e50cada3aec4fc3b4c494a70d328672c (diff) | |
download | pleroma-0f0acc740d30c47d093f27875d4decf0693b2845.tar.gz pleroma-0f0acc740d30c47d093f27875d4decf0693b2845.zip |
Chat: Allow posting without content if an attachment is present.
Diffstat (limited to 'test/web/activity_pub')
-rw-r--r-- | test/web/activity_pub/object_validator_test.exs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/web/activity_pub/object_validator_test.exs b/test/web/activity_pub/object_validator_test.exs index d9f5a8fac..da33d3dbc 100644 --- a/test/web/activity_pub/object_validator_test.exs +++ b/test/web/activity_pub/object_validator_test.exs @@ -103,6 +103,38 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do assert object["attachment"] end + test "validates for a basic object with an attachment but without content", %{ + valid_chat_message: valid_chat_message, + user: user + } do + file = %Plug.Upload{ + content_type: "image/jpg", + path: Path.absname("test/fixtures/image.jpg"), + filename: "an_image.jpg" + } + + {:ok, attachment} = ActivityPub.upload(file, actor: user.ap_id) + + valid_chat_message = + valid_chat_message + |> Map.put("attachment", attachment.data) + |> Map.delete("content") + + assert {:ok, object, _meta} = ObjectValidator.validate(valid_chat_message, []) + + assert object["attachment"] + end + + test "does not validate if the message has no content", %{ + valid_chat_message: valid_chat_message + } do + contentless = + valid_chat_message + |> Map.delete("content") + + refute match?({:ok, _object, _meta}, ObjectValidator.validate(contentless, [])) + end + test "does not validate if the message is longer than the remote_limit", %{ valid_chat_message: valid_chat_message } do |