1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.MRF.MentionPolicy do
6 @moduledoc "Block messages which mention a user"
8 @behaviour Pleroma.Web.ActivityPub.MRF.Policy
11 def filter(%{"type" => "Create"} = message) do
12 reject_actors = Pleroma.Config.get([:mrf_mention, :actors], [])
13 recipients = (message["to"] || []) ++ (message["cc"] || [])
16 Enum.find(recipients, fn recipient -> Enum.member?(reject_actors, recipient) end) do
17 {:reject, "[MentionPolicy] Rejected for mention of #{rejected_mention}"}
24 def filter(message), do: {:ok, message}
27 def describe, do: {:ok, %{}}
30 def config_description do
33 related_policy: "Pleroma.Web.ActivityPub.MRF.MentionPolicy",
35 description: "Block messages which mention a specific user",
39 type: {:list, :string},
40 description: "A list of actors for which any post mentioning them will be dropped",
41 suggestions: ["actor1", "actor2"]