mirror of
https://git.pleroma.social/sjw/pleroma.git
synced 2024-12-23 19:55:03 +01:00
Don't go through all available emoji.
object carry their emoji information.
This commit is contained in:
parent
e30752bc79
commit
df8fc72491
@ -110,14 +110,10 @@ defmodule Pleroma.Formatter 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 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
|
||||
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 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
|
||||
content
|
||||
end
|
||||
|
||||
html = HtmlSanitizeEx.basic_html(content) |> Formatter.emojify(object["emoji"])
|
||||
html = HtmlSanitizeEx.basic_html(content)
|
||||
|> Formatter.emojify(object["emoji"])
|
||||
|
||||
%{
|
||||
"id" => activity.id,
|
||||
|
Loading…
Reference in New Issue
Block a user