Allow emojis to be added automatically

This commit is contained in:
Jorty 2018-06-30 15:08:31 -04:00
parent d386e8a825
commit 0bfbf15b37
1 changed files with 19 additions and 1 deletions

View File

@ -173,7 +173,25 @@ def version(conn, _params) do
end
def emoji(conn, _params) do
json(conn, Enum.into(Formatter.get_custom_emoji(), %{}))
emoji_dir = Path.join(:code.priv_dir(:pleroma), "static/emoji")
shortcode_emoji_glob =
Path.join(
emoji_dir,
Application.get_env(:pleroma, :emoji, []) |>
Keyword.get(:glob, "by-shortcode/**/*.png")
)
shortcode_emoji =
Path.wildcard(shortcode_emoji_glob) |>
Enum.map(fn path ->
shortcode = Path.basename(path, ".png")
serve_path = Path.join("/emoji", Path.relative_to(path, emoji_dir))
{shortcode, serve_path}
end)
emoji = Enum.into(Formatter.get_custom_emoji(), shortcode_emoji) |> Enum.into(%{})
json(conn, emoji)
end
def follow_import(conn, %{"list" => %Plug.Upload{} = listfile}) do