Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into develop
[akkoma] / lib / pleroma / web / activity_pub / mrf / no_placeholder_text_policy.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2019 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
8
9 @impl true
10 def filter(
11 %{
12 "type" => "Create",
13 "object" => %{"content" => content, "attachment" => _attachment} = child_object
14 } = object
15 )
16 when content in [".", "<p>.</p>"] do
17 child_object =
18 child_object
19 |> Map.put("content", "")
20
21 object =
22 object
23 |> Map.put("object", child_object)
24
25 {:ok, object}
26 end
27
28 @impl true
29 def filter(object), do: {:ok, object}
30 end