def emoji_url(_), do: nil
+ def emoji_name_with_instance(name, url) do
+ url = url |> URI.parse() |> Map.get(:host)
+ "#{name}@#{url}"
+ end
+
emoji_qualification_map =
emojis
|> Enum.filter(&String.contains?(&1, "\uFE0F"))
assert {:ok, ^expected, []} = Builder.note(draft)
end
end
+
+ describe "emoji_react/1" do
+ test "unicode emoji" do
+ user = insert(:user)
+ note = insert(:note)
+
+ assert {:ok, %{"content" => "👍", "type" => "EmojiReact"}, []} =
+ Builder.emoji_react(user, note, "👍")
+ end
+
+ test "custom emoji" do
+ user = insert(:user)
+ note = insert(:note)
+
+ assert {:ok,
+ %{
+ "content" => ":dinosaur:",
+ "type" => "EmojiReact",
+ "tag" => [
+ %{
+ "name" => ":dinosaur:",
+ "id" => "http://localhost:4001/emoji/dino walking.gif",
+ "icon" => %{
+ "type" => "Image",
+ "url" => "http://localhost:4001/emoji/dino walking.gif"
+ }
+ }
+ ]
+ }, []} = Builder.emoji_react(user, note, ":dinosaur:")
+ end
+
+ test "remote custom emoji" do
+ user = insert(:user)
+ other_user = insert(:user, local: false)
+ note = insert(:note, data: %{"reactions" => [["wow", [other_user.ap_id], "https://remote/emoji/wow"]]})
+
+ assert {:ok,
+ %{
+ "content" => ":wow:",
+ "type" => "EmojiReact",
+ "tag" => [
+ %{
+ "name" => ":wow:",
+ "id" => "https://remote/emoji/wow",
+ "icon" => %{
+ "type" => "Image",
+ "url" => "https://remote/emoji/wow"
+ }
+ }
+ ]
+ }, []} = Builder.emoji_react(user, note, ":wow@remote:")
+ end
+ end
end