Revert "Longer timeouts for user fetching."
[akkoma] / lib / pleroma / formatter.ex
index e9f4bf06bf0231e089c06d58b09336347525e6aa..f062d9a5896b6e928e8f253c86c1978d0e2c0c57 100644 (file)
@@ -93,11 +93,23 @@ defmodule Pleroma.Formatter do
     {finmoji, "/finmoji/128px/#{finmoji}-128.png"}
   end)
 
-  @emoji @finmoji_with_filenames
+  @emoji_from_file (with {:ok, file} <- File.read("config/emoji.txt") do
+                     file
+                     |> String.trim
+                     |> String.split("\n")
+                     |> Enum.map(fn(line) ->
+                       [name, file] = String.split(line, ", ")
+                       {name, file}
+                     end)
+                    else
+                      _ -> []
+                   end)
+
+  @emoji @finmoji_with_filenames ++ @emoji_from_file
 
   def emojify(text, additional \\ nil) do
     all_emoji = if additional do
-      @emoji ++ Map.to_list(additional)
+      Map.to_list(additional) ++ @emoji
     else
       @emoji
     end
@@ -110,4 +122,9 @@ defmodule Pleroma.Formatter do
   def get_emoji(text) do
     Enum.filter(@emoji, fn ({emoji, _}) -> String.contains?(text, ":#{emoji}:") end)
   end
+
+  def get_custom_emoji() do
+    @emoji
+    |> Enum.into %{}
+  end
 end