activitypub: mrf: tag policy: add support for subscription control
authorWilliam Pitcock <nenolod@dereferenced.org>
Mon, 4 Feb 2019 17:48:48 +0000 (17:48 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 4 Feb 2019 17:48:48 +0000 (17:48 +0000)
lib/pleroma/web/activity_pub/mrf/tag_policy.ex

index dd3129707c28b21c441c6910f1c948cfa2ddd834..901a0f2b00c38b7f92025e1a500407e97f5f9529 100644 (file)
@@ -85,6 +85,21 @@ defmodule Pleroma.Web.ActivityPub.MRF.TagPolicy do
     end
   end
 
+  defp process_tag(
+         "mrf_tag:disable-remote-subscription",
+         %{"type" => "Follow", "actor" => actor} = message
+       ) do
+    user = User.get_cached_by_ap_id(actor)
+
+    if user.local == true do
+      {:ok, message}
+    else
+      {:reject, nil}
+    end
+  end
+
+  defp process_tag("mrf_tag:disable-any-subscription", %{"type" => "Follow"}), do: {:reject, nil}
+
   defp process_tag(_, message), do: {:ok, message}
 
   def filter_message(actor, message) do