- if actor_info.host in @media_nsfw and child_object["attachment"] != nil and
- length(child_object["attachment"]) > 0 do
- tags = (child_object["tag"] || []) ++ ["nsfw"]
- child_object = Map.put(child_object, "tags", tags)
- child_object = Map.put(child_object, "sensitive", true)
- object = Map.put(object, "object", child_object)
- {:ok, object}
+ object =
+ if MRF.subdomain_match?(media_nsfw, actor_host) do
+ tags = (child_object["tag"] || []) ++ ["nsfw"]
+ child_object = Map.put(child_object, "tag", tags)
+ child_object = Map.put(child_object, "sensitive", true)
+ Map.put(object, "object", child_object)
+ else
+ object
+ end
+
+ {:ok, object}
+ end
+
+ defp check_media_nsfw(_actor_info, object), do: {:ok, object}
+
+ defp check_ftl_removal(%{host: actor_host} = _actor_info, object) do
+ timeline_removal =
+ Pleroma.Config.get([:mrf_simple, :federated_timeline_removal])
+ |> MRF.subdomains_regex()
+
+ object =
+ with true <- MRF.subdomain_match?(timeline_removal, actor_host),
+ user <- User.get_cached_by_ap_id(object["actor"]),
+ true <- "https://www.w3.org/ns/activitystreams#Public" in object["to"] do
+ to =
+ List.delete(object["to"], "https://www.w3.org/ns/activitystreams#Public") ++
+ [user.follower_address]
+
+ cc =
+ List.delete(object["cc"], user.follower_address) ++
+ ["https://www.w3.org/ns/activitystreams#Public"]
+
+ object
+ |> Map.put("to", to)
+ |> Map.put("cc", cc)
+ else
+ _ -> object
+ end
+
+ {:ok, object}
+ end
+
+ defp check_report_removal(%{host: actor_host} = _actor_info, %{"type" => "Flag"} = object) do
+ report_removal =
+ Pleroma.Config.get([:mrf_simple, :report_removal])
+ |> MRF.subdomains_regex()
+
+ if MRF.subdomain_match?(report_removal, actor_host) do
+ {:reject, nil}