Fix incorrect multiple emoji tag handling introduced in initial impl

This commit is contained in:
Ekaterina Vaartis 2019-04-18 21:17:52 +03:00
parent 9bd5e2dec9
commit 52ed287e87
4 changed files with 10 additions and 11 deletions

View file

@ -147,8 +147,7 @@ defmodule Pleroma.Emoji do
|> Enum.map(fn {shortcode, rel_file} -> |> Enum.map(fn {shortcode, rel_file} ->
filename = Path.join(common_pack_path, rel_file) filename = Path.join(common_pack_path, rel_file)
# If no tag matches, use the pack name as a tag {shortcode, filename, [to_string(match_extra(@groups, filename))]}
{shortcode, filename, to_string(match_extra(@groups, filename))}
end) end)
end end
end end
@ -190,11 +189,11 @@ defmodule Pleroma.Emoji do
|> Stream.map(&String.trim/1) |> Stream.map(&String.trim/1)
|> Stream.map(fn line -> |> Stream.map(fn line ->
case String.split(line, ~r/,\s*/) do case String.split(line, ~r/,\s*/) do
[name, file, tags] ->
{name, file, tags}
[name, file] -> [name, file] ->
{name, file, to_string(match_extra(@groups, file))} {name, file, [to_string(match_extra(@groups, file))]}
[name, file | tags] ->
{name, file, tags}
_ -> _ ->
nil nil
@ -217,7 +216,7 @@ defmodule Pleroma.Emoji do
tag = match_extra(@groups, Path.join("/", Path.relative_to(path, static_path))) tag = match_extra(@groups, Path.join("/", Path.relative_to(path, static_path)))
shortcode = Path.basename(path, Path.extname(path)) shortcode = Path.basename(path, Path.extname(path))
external_path = Path.join("/", Path.relative_to(path, static_path)) external_path = Path.join("/", Path.relative_to(path, static_path))
{shortcode, external_path, to_string(tag)} {shortcode, external_path, [to_string(tag)]}
end) end)
end end

View file

@ -190,7 +190,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
"static_url" => url, "static_url" => url,
"visible_in_picker" => true, "visible_in_picker" => true,
"url" => url, "url" => url,
"tags" => String.split(tags, ",") "tags" => tags
} }
end) end)
end end

View file

@ -286,7 +286,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
emoji = emoji =
Emoji.get_all() Emoji.get_all()
|> Enum.map(fn {short_code, path, tags} -> |> Enum.map(fn {short_code, path, tags} ->
{short_code, %{image_url: path, tags: String.split(tags, ",")}} {short_code, %{image_url: path, tags: tags}}
end) end)
|> Enum.into(%{}) |> Enum.into(%{})

View file

@ -15,7 +15,7 @@ defmodule Pleroma.EmojiTest do
assert tuple_size(emoji) == 3 assert tuple_size(emoji) == 3
assert is_binary(code) assert is_binary(code)
assert is_binary(path) assert is_binary(path)
assert is_binary(tags) assert is_list(tags)
end end
test "random emoji", %{emoji_list: emoji_list} do test "random emoji", %{emoji_list: emoji_list} do
@ -25,7 +25,7 @@ defmodule Pleroma.EmojiTest do
assert tuple_size(emoji) == 3 assert tuple_size(emoji) == 3
assert is_binary(code) assert is_binary(code)
assert is_binary(path) assert is_binary(path)
assert is_binary(tags) assert is_list(tags)
end end
end end