ChatMessageValidator: Additional validation.
[akkoma] / test / web / activity_pub / object_validator_test.exs
index e9655276354a0257ebed20c01ed7d2933365e6bb..c1a87229751416b4f91885cb6aeb27410c9a3672 100644 (file)
@@ -223,6 +223,17 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do
       refute match?({:ok, _object, _meta}, ObjectValidator.validate(valid_chat_message, []))
     end
 
+    test "does not validate if the recipient is not accepting chat messages", %{
+      valid_chat_message: valid_chat_message,
+      recipient: recipient
+    } do
+      recipient
+      |> Ecto.Changeset.change(%{accepts_chat_messages: false})
+      |> Pleroma.Repo.update!()
+
+      refute match?({:ok, _object, _meta}, ObjectValidator.validate(valid_chat_message, []))
+    end
+
     test "does not validate if the actor or the recipient is not in our system", %{
       valid_chat_message: valid_chat_message
     } do
@@ -657,7 +668,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do
 
   describe "blocks" do
     setup do
-      user = insert(:user)
+      user = insert(:user, local: false)
       blocked = insert(:user)
 
       {:ok, valid_block, []} = Builder.block(user, blocked)