Merge branch 'develop' into 'remove-twitter-api'
[akkoma] / docs / configuration / mrf.md
index 9b2289e7c47af79e9772c20b4a11955c04c62748..d48d0cc991abd89db3e99079ebed96fd46cd976f 100644 (file)
@@ -41,11 +41,15 @@ config :pleroma, :instance,
 
 Once `SimplePolicy` is enabled, you can configure various groups in the `:mrf_simple` config object. These groups are:
 
-* `media_removal`: Servers in this group will have media stripped from incoming messages.
-* `media_nsfw`: Servers in this group will have the #nsfw tag and sensitive setting injected into incoming messages which contain media.
 * `reject`: Servers in this group will have their messages rejected.
-* `federated_timeline_removal`: Servers in this group will have their messages unlisted from the public timelines by flipping the `to` and `cc` fields.
+* `accept`: If not empty, only messages from these instances will be accepted (whitelist federation).
+* `media_nsfw`: Servers in this group will have the #nsfw tag and sensitive setting injected into incoming messages which contain media.
+* `media_removal`: Servers in this group will have media stripped from incoming messages.
+* `avatar_removal`: Avatars from these servers will be stripped from incoming messages.
+* `banner_removal`: Banner images from these servers will be stripped from incoming messages.
 * `report_removal`: Servers in this group will have their reports (flags) rejected.
+* `federated_timeline_removal`: Servers in this group will have their messages unlisted from the public timelines by flipping the `to` and `cc` fields.
+* `reject_deletes`: Deletion requests will be rejected from these servers.
 
 Servers should be configured as lists.
 
@@ -76,16 +80,18 @@ As discussed above, the MRF system is a modular system that supports pluggable p
 For example, here is a sample policy module which rewrites all messages to "new message content":
 
 ```elixir
-# This is a sample MRF policy which rewrites all Notes to have "new message
-# content."
-defmodule Site.RewritePolicy do
-  @behavior Pleroma.Web.ActivityPub.MRF
+defmodule Pleroma.Web.ActivityPub.MRF.RewritePolicy do
+  @moduledoc "MRF policy which rewrites all Notes to have 'new message content'."
+  @behaviour Pleroma.Web.ActivityPub.MRF
 
   # Catch messages which contain Note objects with actual data to filter.
   # Capture the object as `object`, the message content as `content` and the
   # message itself as `message`.
   @impl true
-  def filter(%{"type" => "Create", "object" => {"type" => "Note", "content" => content} = object} = message)
+  def filter(
+        %{"type" => "Create", "object" => %{"type" => "Note", "content" => content} = object} =
+          message
+      )
       when is_binary(content) do
     # Subject / CW is stored as summary instead of `name` like other AS2 objects
     # because of Mastodon doing it that way.
@@ -108,16 +114,21 @@ defmodule Site.RewritePolicy do
   # Let all other messages through without modifying them.
   @impl true
   def filter(message), do: {:ok, message}
+
+  @impl true
+  def describe do
+    {:ok, %{mrf_sample: %{content: "new message content"}}}
+  end
 end
 ```
 
-If you save this file as `lib/site/mrf/rewrite_policy.ex`, it will be included when you next rebuild Pleroma. You can enable it in the configuration like so:
+If you save this file as `lib/pleroma/web/activity_pub/mrf/rewrite_policy.ex`, it will be included when you next rebuild Pleroma.  You can enable it in the configuration like so:
 
 ```elixir
 config :pleroma, :instance,
   rewrite_policy: [
     Pleroma.Web.ActivityPub.MRF.SimplePolicy,
-    Site.RewritePolicy
+    Pleroma.Web.ActivityPub.MRF.RewritePolicy
   ]
 ```