Add emoji_url to notifications to allow rendering
[akkoma] / lib / pleroma / emoji.ex
index d421f2ccb42d74cec2748b905941769de4004418..f4043ac80b9d317ab6c39369b5d7cc69cd74ecdf 100644 (file)
@@ -164,4 +164,22 @@ defmodule Pleroma.Emoji do
   end
 
   def maybe_quote(name), do: name
+
+  def emoji_url(%{"type" => "EmojiReact", "content" => emoji, "tag" => []}), do: nil
+
+  def emoji_url(%{"type" => "EmojiReact", "content" => emoji, "tag" => tags}) do
+    tag =
+      tags
+      |> Enum.find(fn tag -> tag["type"] == "Emoji" && tag["name"] == stripped_name(emoji) end)
+
+    if is_nil(tag) do
+      nil
+    else
+      tag
+      |> Map.get("icon")
+      |> Map.get("url")
+    end
+  end
+
+  def emoji_url(_), do: nil
 end