Commit df8fc724 authored by lain's avatar lain
Browse files

Don't go through all available emoji.

object carry their emoji information.
parent e30752bc
Pipeline #1004 passed with stage
in 3 minutes and 3 seconds
......@@ -110,14 +110,10 @@ def parse_mentions(text) do
@emoji @finmoji_with_filenames ++ @emoji_from_file
def emojify(text, additional \\ nil) do
all_emoji = if additional do
Map.to_list(additional) ++ @emoji
else
@emoji
end
Enum.reduce(all_emoji, text, fn ({emoji, file}, text) ->
def emojify(text, emoji \\ @emoji)
def emojify(text, nil), do: text
def emojify(text, emoji) do
Enum.reduce(emoji, text, fn ({emoji, file}, text) ->
emoji = HtmlSanitizeEx.strip_tags(emoji)
file = HtmlSanitizeEx.strip_tags(file)
String.replace(text, ":#{emoji}:", "<img height='32px' width='32px' alt='#{emoji}' title='#{emoji}' src='#{MediaProxy.url(file)}' />")
......
......@@ -145,7 +145,8 @@ def to_map(%Activity{data: %{"object" => %{"content" => content} = object}} = ac
content
end
html = HtmlSanitizeEx.basic_html(content) |> Formatter.emojify(object["emoji"])
html = HtmlSanitizeEx.basic_html(content)
|> Formatter.emojify(object["emoji"])
%{
"id" => activity.id,
......
......@@ -37,7 +37,8 @@ def render("activity.json", %{activity: %{data: %{"type" => "Create", "object" =
content
end
html = HtmlSanitizeEx.basic_html(content) |> Formatter.emojify(object["emoji"])
html = HtmlSanitizeEx.basic_html(content)
|> Formatter.emojify(object["emoji"])
%{
"id" => activity.id,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment