Rename search.ex to database_search.ex and add search/2
[akkoma] / lib / pleroma / web / translation_helpers.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.TranslationHelpers do
6 defmacro render_error(
7 conn,
8 status,
9 msgid,
10 bindings \\ Macro.escape(%{}),
11 identifier \\ Macro.escape("")
12 ) do
13 quote do
14 require Pleroma.Web.Gettext
15
16 error_map =
17 %{
18 error: Pleroma.Web.Gettext.dgettext("errors", unquote(msgid), unquote(bindings)),
19 identifier: unquote(identifier)
20 }
21 |> Enum.reject(fn {_k, v} -> v == "" end)
22 |> Map.new()
23
24 unquote(conn)
25 |> Plug.Conn.put_status(unquote(status))
26 |> Phoenix.Controller.json(error_map)
27 end
28 end
29 end