From ffa1b00fa1d961b85730fd6067ff988257702c55 Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Tue, 10 Nov 2020 10:07:29 +0300 Subject: [PATCH] fix ecto helpers --- lib/pleroma/ecto_helper.ex | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/pleroma/ecto_helper.ex b/lib/pleroma/ecto_helper.ex index b174ea41c..3bc5d9d79 100644 --- a/lib/pleroma/ecto_helper.ex +++ b/lib/pleroma/ecto_helper.ex @@ -22,19 +22,14 @@ defmodule Pleroma.EctoHelper do end defp do_prettify({field_name, {msg, variables}}, mapping_fields) do - compound_message = do_interpolate(msg, variables) - do_prettify({field_name, compound_message}, mapping_fields) + do_prettify({field_name, do_interpolate(msg, variables)}, mapping_fields) end defp do_interpolate(string, [{name, value} | rest]) do - n = Atom.to_string(name) - msg = String.replace(string, "%{#{n}}", do_to_string(value)) - do_interpolate(msg, rest) + string + |> String.replace("%{#{name}}", to_string(value)) + |> do_interpolate(rest) end defp do_interpolate(string, []), do: string - - defp do_to_string(value) when is_integer(value), do: Integer.to_string(value) - defp do_to_string(value) when is_bitstring(value), do: value - defp do_to_string(value) when is_atom(value), do: Atom.to_string(value) end