projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
OpenAPI: fix various errors pointed out by editor.swagger.io
[akkoma]
/
lib
/
pleroma
/
emoji
/
formatter.ex
diff --git
a/lib/pleroma/emoji/formatter.ex
b/lib/pleroma/emoji/formatter.ex
index 59ff2cac35144f49b830ddfcd1a22ad507195297..dc45b8a38ed4a0bb6834dd456705735752c16a9d 100644
(file)
--- a/
lib/pleroma/emoji/formatter.ex
+++ b/
lib/pleroma/emoji/formatter.ex
@@
-38,22
+38,14
@@
defmodule Pleroma.Emoji.Formatter do
def demojify(text, nil), do: text
def demojify(text, nil), do: text
- @doc "Outputs a list of the emoji-shortcodes in a text"
- def get_emoji(text) when is_binary(text) do
- Enum.filter(Emoji.get_all(), fn {emoji, %Emoji{}} ->
- String.contains?(text, ":#{emoji}:")
- end)
- end
-
- def get_emoji(_), do: []
-
@doc "Outputs a list of the emoji-Maps in a text"
def get_emoji_map(text) when is_binary(text) do
@doc "Outputs a list of the emoji-Maps in a text"
def get_emoji_map(text) when is_binary(text) do
- get_emoji(text)
+ Emoji.get_all()
+ |> Enum.filter(fn {emoji, %Emoji{}} -> String.contains?(text, ":#{emoji}:") end)
|> Enum.reduce(%{}, fn {name, %Emoji{file: file}}, acc ->
Map.put(acc, name, "#{Pleroma.Web.Endpoint.static_url()}#{file}")
end)
end
|> Enum.reduce(%{}, fn {name, %Emoji{file: file}}, acc ->
Map.put(acc, name, "#{Pleroma.Web.Endpoint.static_url()}#{file}")
end)
end
- def get_emoji_map(_), do:
[]
+ def get_emoji_map(_), do:
%{}
end
end