extend reject MRF to check if originating instance is blocked
[akkoma] / lib / pleroma / web / activity_pub / mrf / no_placeholder_text_policy.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ActivityPub.MRF.NoPlaceholderTextPolicy do
6 @moduledoc "Ensure no content placeholder is present (such as the dot from mastodon)"
7 @behaviour Pleroma.Web.ActivityPub.MRF.Policy
8
9 @impl true
10 def history_awareness, do: :auto
11
12 @impl true
13 def filter(
14 %{
15 "type" => type,
16 "object" => %{"content" => content, "attachment" => _} = _child_object
17 } = object
18 )
19 when type in ["Create", "Update"] and content in [".", "<p>.</p>"] do
20 {:ok, put_in(object, ["object", "content"], "")}
21 end
22
23 @impl true
24 def filter(object), do: {:ok, object}
25
26 @impl true
27 def describe, do: {:ok, %{}}
28 end