summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfeld <feld@feld.me>2020-02-18 21:03:01 +0000
committerfeld <feld@feld.me>2020-02-18 21:03:01 +0000
commit3b78695c9828bc49a5c7706437af5f24fc4475de (patch)
tree0b65513f42a8959b705d6e8b74d80a160becf74b
parent3416948cdf048421fb042fb71f54d2868d291aca (diff)
parent53a7680c161d3bc7b046ec576e5269de668f547f (diff)
Merge branch 'fix/mrf-sample-doc' into 'develop'
Update MRF docs, make sample code actually compile See merge request pleroma/pleroma!2210
-rw-r--r--docs/configuration/mrf.md21
1 files changed, 14 insertions, 7 deletions
diff --git a/docs/configuration/mrf.md b/docs/configuration/mrf.md
index 9b2289e7c..c3957c255 100644
--- a/docs/configuration/mrf.md
+++ b/docs/configuration/mrf.md
@@ -76,16 +76,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 +110,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
]
```