Fix MRF policies to also work with Update
[akkoma] / test / pleroma / web / activity_pub / mrf / no_empty_policy_test.exs
index fbcf6841416bc13640e52a8445e66e1f7bef53fe..d9e05d3131f3f8dede09d27f4cd1c86ed13f69c0 100644 (file)
@@ -16,7 +16,9 @@ defmodule Pleroma.Web.ActivityPub.MRF.NoEmptyPolicyTest do
         "actor" => "http://localhost:4001/users/testuser",
         "attachment" => [],
         "cc" => ["http://localhost:4001/users/testuser/followers"],
-        "source" => "this is a test post",
+        "source" => %{
+          "content" => "this is a test post"
+        },
         "to" => ["https://www.w3.org/ns/activitystreams#Public"],
         "type" => "Note"
       },
@@ -151,4 +153,27 @@ defmodule Pleroma.Web.ActivityPub.MRF.NoEmptyPolicyTest do
 
     assert NoEmptyPolicy.filter(message) == {:reject, "[NoEmptyPolicy]"}
   end
+
+  test "works with Update" do
+    message = %{
+      "actor" => "http://localhost:4001/users/testuser",
+      "cc" => ["http://localhost:4001/users/testuser/followers"],
+      "object" => %{
+        "actor" => "http://localhost:4001/users/testuser",
+        "attachment" => [],
+        "cc" => ["http://localhost:4001/users/testuser/followers"],
+        "source" => "",
+        "to" => [
+          "https://www.w3.org/ns/activitystreams#Public"
+        ],
+        "type" => "Note"
+      },
+      "to" => [
+        "https://www.w3.org/ns/activitystreams#Public"
+      ],
+      "type" => "Update"
+    }
+
+    assert NoEmptyPolicy.filter(message) == {:reject, "[NoEmptyPolicy]"}
+  end
 end