Handle MRF rejections of incoming AP activities
authorSergey Suprunenko <suprunenko.s@gmail.com>
Sat, 3 Aug 2019 18:12:38 +0000 (18:12 +0000)
committerkaniini <ariadne@dereferenced.org>
Sat, 3 Aug 2019 18:12:38 +0000 (18:12 +0000)
lib/pleroma/web/activity_pub/activity_pub.ex
test/web/federator_test.exs

index 07a65127b60d9c44d1cf6ac4b4b778f3fcbebc85..2877c029e0c61f9c6e2889cbebc6543f5e16fe3f 100644 (file)
@@ -267,6 +267,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     else
       {:fake, true, activity} ->
         {:ok, activity}
+
+      {:error, message} ->
+        {:error, message}
     end
   end
 
index 6e143eee48f03d467e4865fd18af8b01c204db67..73cfaa8f1ec96dbb681ba44ccd4427dfd1a139ed 100644 (file)
@@ -229,5 +229,21 @@ defmodule Pleroma.Web.FederatorTest do
 
       :error = Federator.incoming_ap_doc(params)
     end
+
+    test "it does not crash if MRF rejects the post" do
+      policies = Pleroma.Config.get([:instance, :rewrite_policy])
+      mrf_keyword_policy = Pleroma.Config.get(:mrf_keyword)
+      Pleroma.Config.put([:mrf_keyword, :reject], ["lain"])
+      Pleroma.Config.put([:instance, :rewrite_policy], Pleroma.Web.ActivityPub.MRF.KeywordPolicy)
+
+      params =
+        File.read!("test/fixtures/mastodon-post-activity.json")
+        |> Poison.decode!()
+
+      assert Federator.incoming_ap_doc(params) == :error
+
+      Pleroma.Config.put([:instance, :rewrite_policy], policies)
+      Pleroma.Config.put(:mrf_keyword, mrf_keyword_policy)
+    end
   end
 end