From 0bfbf15b379a95e7fad50e8f611cf6c5e67cfa9c Mon Sep 17 00:00:00 2001 From: Jorty Date: Sat, 30 Jun 2018 15:08:31 -0400 Subject: [PATCH] Allow emojis to be added automatically --- .../web/twitter_api/controllers/util_controller.ex | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex index 7a0c37ce9..db6142dc8 100644 --- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex +++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex @@ -173,7 +173,25 @@ defmodule Pleroma.Web.TwitterAPI.UtilController 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