logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

no_placeholder_text_policy.ex (820B)


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