def check_simple_policy_tuples do
has_strings =
Config.get([:mrf_simple])
- |> Enum.any?(fn {_, v} -> Enum.any?(v, fn e -> is_binary(e) end) end)
+ |> Enum.any?(fn {_, v} -> Enum.any?(v, &is_binary/1) end)
if has_strings do
Logger.warn("""
end
def check_quarantined_instances_tuples do
- has_strings =
- Config.get([:instance, :quarantined_instances]) |> Enum.any?(fn e -> is_binary(e) end)
+ has_strings = Config.get([:instance, :quarantined_instances]) |> Enum.any?(&is_binary/1)
if has_strings do
Logger.warn("""
end
def check_transparency_exclusions_tuples do
- has_strings =
- Config.get([:mrf, :transparency_exclusions]) |> Enum.any?(fn e -> is_binary(e) end)
+ has_strings = Config.get([:mrf, :transparency_exclusions]) |> Enum.any?(&is_binary/1)
if has_strings do
Logger.warn("""
@impl true
def describe,
- do: {:ok, %{mrf_rejectnonpublic: Config.get(:mrf_rejectnonpublic) |> Enum.into(%{})}}
+ do: {:ok, %{mrf_rejectnonpublic: Config.get(:mrf_rejectnonpublic) |> Map.new()}}
@impl true
def config_description do
mrf_simple_excluded =
Config.get(:mrf_simple)
- |> Enum.map(fn {k, v} -> {k, Enum.reject(v, fn {v, _} -> v in exclusions end)} end)
+ |> Enum.map(fn {rule, instances} ->
+ {rule, Enum.reject(instances, fn {host, _} -> host in exclusions end)}
+ end)
mrf_simple =
mrf_simple_excluded
- |> Enum.map(fn {k, v} ->
- {k, Enum.map(v, fn {instance, _} -> instance end)}
+ |> Enum.map(fn {rule, instances} ->
+ {rule, Enum.map(instances, fn {host, _} -> host end)}
end)
- |> Enum.into(%{})
+ |> Map.new()
# This is for backwards compatibility. We originally didn't sent
# extra info like a reason why an instance was rejected/quarantined/etc.
# to add an extra "info" key.
mrf_simple_info =
mrf_simple_excluded
- |> Enum.map(fn {k, v} -> {k, Enum.reject(v, fn {_, reason} -> reason == "" end)} end)
- |> Enum.reject(fn {_, v} -> v == [] end)
- |> Enum.map(fn {k, l} ->
- {k, l |> Enum.map(fn {i, r} -> {i, %{"reason" => r}} end) |> Enum.into(%{})}
+ |> Enum.map(fn {rule, instances} ->
+ {rule, Enum.reject(instances, fn {_, reason} -> reason == "" end)}
+ end)
+ |> Enum.reject(fn {_, instances} -> instances == [] end)
+ |> Enum.map(fn {rule, instances} ->
+ instances =
+ instances
+ |> Enum.map(fn {host, reason} -> {host, %{"reason" => reason}} end)
+ |> Map.new()
+
+ {rule, instances}
end)
- |> Enum.into(%{})
+ |> Map.new()
{:ok, %{mrf_simple: mrf_simple, mrf_simple_info: mrf_simple_info}}
end
def describe do
mrf_user_allowlist =
Config.get([:mrf_user_allowlist], [])
- |> Enum.into(%{}, fn {k, v} -> {k, length(v)} end)
+ |> Map.new(fn {k, v} -> {k, length(v)} end)
{:ok, %{mrf_user_allowlist: mrf_user_allowlist}}
end
@impl true
def describe,
- do: {:ok, %{mrf_vocabulary: Pleroma.Config.get(:mrf_vocabulary) |> Enum.into(%{})}}
+ do: {:ok, %{mrf_vocabulary: Pleroma.Config.get(:mrf_vocabulary) |> Map.new()}}
@impl true
def config_description do
{:ok, data} = MRF.describe()
data
- |> Map.merge(%{
- quarantined_instances:
- quarantined
- |> Enum.map(fn {instance, _reason} -> instance end)
- })
+ |> Map.put(
+ :quarantined_instances,
+ Enum.map(quarantined, fn {instance, _reason} -> instance end)
+ )
# This is for backwards compatibility. We originally didn't sent
# extra info like a reason why an instance was rejected/quarantined/etc.
# Because we didn't want to break backwards compatibility it was decided
# to add an extra "info" key.
- |> Map.merge(%{
- quarantined_instances_info: %{
- "quarantined_instances" =>
- quarantined
- |> Enum.map(fn {instance, reason} -> {instance, %{"reason" => reason}} end)
- |> Enum.into(%{})
- }
+ |> Map.put(:quarantined_instances_info, %{
+ "quarantined_instances" =>
+ quarantined
+ |> Enum.map(fn {instance, reason} -> {instance, %{"reason" => reason}} end)
+ |> Map.new()
})
else
%{}